This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes nested forEach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "nested forEach " Watch "nested forEach " New topic
Author

nested forEach

Vinod Awar
Ranch Hand

Joined: Nov 06, 2006
Posts: 125
Hii all,

i want to display the result of a database query .In the servlet what i did is


and in the jsp i am trying to display them like this


But i can only see the columnnames. is there anything wrong in my nested forEach loop code

Thanks,
Vinod


The biggest bankruptcy is the loss of enthusiasm
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The problem isn't in your JSP.

You're only creating one "fields" object.
Move the declaration for your 'fields' object into the loop so a new one gets created for each row and try it again.



[BPSouther: fixed cut and paste error. Thanks Saif!]
[ March 15, 2007: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Ben Souther:



how about Swapping the second line with first line I though it becomes with more clear picture.. ;)


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Saif uddin:


how about Swapping the second line with first line I though it becomes with more clear picture.. ;)


Fixed. Thanks
Vinod Awar
Ranch Hand

Joined: Nov 06, 2006
Posts: 125
Thanks Ben and saif
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: nested forEach
 
Similar Threads
varstatus in nested foreach
Display text from MySQL Text Field
Generate JTable from a SQL Query containing UNION clause
JSTL, JDBC, and Result Set
how iterate arraylist included in a object with c:for