result set

how to insert the contents of a result set in a combo box.

in the jsp page i hv used the usebean tag to create an instance of the class...and i hv the function to get the resultset

i wnt to know how to bind this resultset to the combo box

ie<select>

<option1></option1>

<option2></option2>

</select>

[378 byte] By [prabhath_ma] at [2007-10-3 8:39:29]
# 1
E.g.<select><% while(rs.next()){%><option><%=rs.getString(1)%></option><%}%></select>
harishotya at 2007-7-15 3:47:35 > top of Java-index,Java Essentials,Java Programming...
# 2

Since you have access to the ResultSet (I am not too fond of providing direct access to DB resources in JSP, but I can live with it for now), you just loop over the ResultSet and generate page content for each record.

Example

<%while(rs.next()){%>

...HTML....<%=rs.getXXX(...)%>...HTML...

<%} %>

Mike

bellyrippera at 2007-7-15 3:47:35 > top of Java-index,Java Essentials,Java Programming...