Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL iteration of a list with numbering

 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am iterating over an ArrayList of objects. For each entry I createe a table row encapsulated within a form. In addition to iterate through the ArrayList I need to insert a number within the iteration so that each form element gets it unique id.

If it was scriptlet I would have no problem, but I am using JSTL <c:forEach>



How can I get the value for each iteration and pass it into formID#. Somehow I need to access the iteration number, like the i in for(int i = 0; i<list.size();i++)

I am using JSTL 1.1 and JSP 2.0 with Servlet-API 2.5
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use varStatus attribute of the forEach tag :


varStatus is of type LoopTagStatus. Check the API for the details of this class.
[ August 22, 2007: Message edited by: Christophe Verre ]
 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Christophe Verre:
Use varStatus attribute of the forEach tag :


varStatus is of type LoopTagStatus. Check the API for the details of this class.

[ August 22, 2007: Message edited by: Christophe Verre ]


Thanks, just what I was looking for
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic