• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

how to iterate list in a table using jstl

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic