Increment counter with loop
The varStatus
references to LoopTagStatus
which has a getIndex()
method.
So:
<c:forEach var="tableEntity" items='${requestScope.tables}' varStatus="outer"> <c:forEach var="rowEntity" items='${tableEntity.rows}' varStatus="inner"> <c:out value="${(outer.index * fn:length(tableEntity.rows)) + inner.index}" /> </c:forEach></c:forEach>
See also:
You can use varStatus in your c:forEach loop
In your first example you can get the counter to work properly as follows...
<c:forEach var="tableEntity" items='${requestScope.tables}'> <c:forEach var="rowEntity" items='${tableEntity.rows}' varStatus="count"> my count is ${count.count} </c:forEach></c:forEach>