21 April 2011

How to implement counter for foreach in jsp ?

Solution for jsp 2.0

in for foreach tag you need add varStatus with name and use name.index  in place where you need counter variable:

<c:forEach var="chicks" varStatus="counter" items="${form.girlimageslist}">
  Girl no. ${counter.index} picture path : ${chicks},
</c:forEach>