tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <>
Subject Re: c:forEach & index in looop
Date Wed, 27 Jul 2005 21:53:54 GMT
From: "Marco Mistroni" <>
> i am trying to replace struts logic:iterate with  JSTL c:forEach...
> however,  i need what in logic:iterate is the index in the loop
> is it possible to get it from anywhere?

Section 6.1.3 and 6.4 of the JSTL 1.0 specification talk about the
'varStatus' attribute of <c:forEach> and how to use it to get not only the
index, but the count, and whether or not this is the first or last element
(useful for delimited lists when you don't want the extra delimiter at the

<c:forEach items="${myList}" var="item" varStatus="status">
    <c:out value="item"/> -
    <c:out value="${status.index}"/>,
    <c:out value="${status.count}"/>,
    <c:out value="${status.first}"/>,
    <c:out value="${status.last}"/><br/>

Wendy Smoak

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message