• Post Reply Bookmark Topic Watch Topic
  • New Topic

New to JSP, need help

 
Jawan Reshman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am new to JSP, I am having trouble in implementing nested loops in JSP. I would really appreciate if some one could point out what am I missing in the followin JSP code?
This code works fine with singel loop and whenever I add nested loop it does not show anything.
Thanks for the help.

----------------------------------------
<% int ii=0;
CachedRowSetImpl cr[] = new CachedRowSetImpl[2];
CachedRowSetImpl crs =(CachedRowSetImpl)request.getAttribut("data1");
cr[ii] = (CachedRowSetImpl)request.getAttribute("data2");
cr[ii].next ();
while (crs.next ()) {
%>
<table>
<tr>
<td width="250">
<p align="right"><%=crs.getString("desc")%>
</td>

<td>
<p align="center">
<% while (rs[ii].next()){ %> <%--this is inner loop with trouble--%>
<select>
<option><%=cr[ii].getString("NAME")%>
</select>
<% } %>
</td>

</tr>
</table>
<% }
request.removeAttribute("data1");
request.removeAttribute("data2");
%>
 
Amit KumarS
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi jawan,
few things that i cud figure out are following...

1) in the following lines that u have written check out the spelling of getAttribute().. u are missing one 'e' ate the end

2) and in the following code u are using the rs[ii].next().. i suppose it shud be cr[ii].next().. cause i can't see any variable with the name 'rs'

3) one more thing i wud like to point out that u r using resultset inside loop and ur cr[ii] resultset is not scrollable then during first loop the cursor will reach the end of the resultset. and when next time u will try to access the same resultset it will give an error as u hace already reached the end of resultset.
4) one more thing, u r using

and then again u r using

in this case it will not give any error but the resultset will be moved one result forward and first record will be skipped.

hope i have cleared the doubts. if still any prob. do let me know.
Bye
Amit
 
Jawan Reshman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,
Thanks for taking your time to look at the code so thoroughly. I have checked the code.
The point which you have raised and its been striking me already (but don't know what to do about it) is
3) one more thing i wud like to point out that u r using resultset inside loop and ur cr[ii] resultset is not scrollable then during first loop the cursor will reach the end of the resultset. and when next time u will try to access the same resultset it will give an error as u hace already reached the end of resultset

Can you please tell me how do I find if my recordset is scrolable?
Any ideas about
com.sun.rowset.CachedRowSetImpl
Once again, thanks a lot for your help and time.
[ April 02, 2004: Message edited by: Jawan Reshman ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!