hi i am having logical error in this code
<option><%=me.getString("pname")%> - <%=me.getString("aname")%>
i am returning a resultset from bean which is saving in 'me'
to get multiple drop down list i used for loop. after each while the resulset cursor will be pointing to the last row so i used me.beforeFirst() to get the cursor back to the first row
Now what is happening here is if i insert 'me.beforeFirst()' then 'for loop' is running only once
Are you trying to get 10 names in multi selection box but you are getting only one. is that what you mean?
Don't do any of this. Get your database results in a servlet or helper class and set the collection in the request scope. Then your JSP simply reads the collection and displays it using EL.
thanx a lot.....
but can u explain why this is not working
ya if i am inserting "me.beforeFirst()"
Read the API specs for the beforeFirst method before using it.
Originally Posted by silversurfer2in
After your first calls to rs.next are done, the result set now contains no rows and beforeFirst on it is no-op.
Originally Posted by r035198x
public boolean first()
Moves the cursor to the first row in this ResultSet object.
true if the cursor is on a valid row; false if there are no rows in the result set
public void beforeFirst()
Moves the cursor to the front of this ResultSet object, just before the first row. This method has no effect if the result set contains no rows.
which one should be used in this case.....since both of them are bringing the cursor from the last row to the first row
I just explained that the specs say This method has no effect if the result set contains no rows. Dump your approach and use the approach I suggested above.