File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSTL iteration of a list with numbering Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL iteration of a list with numbering" Watch "JSTL iteration of a list with numbering" New topic
Author

JSTL iteration of a list with numbering

Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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 ]

[My Blog]
All roads lead to JavaRanch
Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL iteration of a list with numbering