KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
This question is related to my previous question : Jsp iterate trough object list I want to insert counter that starts from 0 in my for loop, I've tried several combinations so far : 1. <c:forEach var="tableEntity" items='${requestScope.tables}'> <c:forEach var="rowEntity" items='${tableEntity.rows}' varStatus="count"> <c:out value="${count}" /> </c:forEach> </c:forEach> 2. <c:set var="count" value="0" scope="page" /> <c:forEach var="tableEntity" items='${requestScope.tables}'> <c:forEach var="rowEntity" items='${tableEntity.rows}'> <%=count++%> <c:out value="${count}" /> </c:forEach> </c:forEach> Problem with first approach is that outer loop has 3 items and inner loop has 7 items, so for each outer item the count starts from 0. The second one I get compile error. Here is basically what I want : counter = 0; outer for loop inner for loop counter++; //cout/echo/print counter value should start from 0 end inner loop end outer loop I'm just not totally familiar with the syntax. thank you
Tags (comma-separated)
Save Edits
Cancel