Win a copy of The Java Performance Companion this week in the Performance forum!
    Bookmark Topic Watch Topic
  • New Topic

example of displaying same collection twice on same page?

 
Ken Hartz
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Report post to moderator
Can anyone provide a quick code example of how to display the same collection twice in the same page using 2 <c:foreach loops?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Use 2 <c:forEach> loops.

What collection is being sent to the page? Most can be iterated over as many times as you'd like, excluding Iterator and Enumeration.
 
Ken Hartz
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks for the response. This relates to our last conversation on iterating over an instance of Map.Entry object. You had stated that a converted ResultSet object to Result object passed to a JSP is an instance of the Map object.

Can you show sample code of simply displaying the above type of list twice in the same page (same list) with using 2 <c:foreach loops?

This seems like a simple issue but I just can't seem get the second <c:foreach loop to display that same list. Can you get 2 separate <c:foreach loops in one page that display the same list in 2 separate areas of page etc...?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
The test code that I showed in that topic can be placed on the page as many times as you'd like.

Since this is a continuation of that topic, I'm going to close this one so that the conversation can continue in the original.
 
    Bookmark Topic Watch Topic
  • New Topic