Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to iterate list in a table using jstl  RSS feed

 
srikanth Thandra
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dear All ,

I am having a List<Menu> called menuList with 1 parent menu having 5 child menu objects. Menu object contains menuName . This list is placed in session scope.

I want to display the above list using jstl in jsp by table element.

Now my requirement of displaying the above list is per Row only 3 td elements should be there.


 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the varStatus attribute of the c:forEach tag. It will tell you the loop counter, so that you can close your row every 3 items.
 
srikanth Thandra
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks for your reply!

I have tried with var Status attribute.But the display of menus is like below:

menu1
menu2
menu3
menu4
menu5

I want the below display format:
menu1 menu2 menu3
menu4 menu5

 
Paul Okeke
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not just like that, you will need to <c:if ... to test and control the condition you need.

Break out of, when your condition if meant.>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Paul said, it's not just like that. Do you understand which properties are available through the varStatus ? If not, download the JSTL specification.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!