Reputation: 1385
I have a requirement where I have to itearate over a map element kept in PageContext, inside jstl fore each . And I am also using an iterator inside the option tag. So I need to make sure the fore each loop iterate 1 less then the actual map size of map al, so that my iterator i
is not iterated completely.
select name="interval" id="interval" onchange="comeback()" >
<%
String s="";
s=(String)portletSession.getAttribute("int1");
%>
<option value="int">Time Interval</option>
<c:forEach var="line" begin="0" end="<%= al.size()-1 %>" items="${al}">
<option <%=((String)((Iterator)portletSession.getAttribute("i")).next()).equals(s)?"selected":" "%> > <c:out value="${line.value}"/></option>
</c:forEach>
<option value="others" <%=((String)((Iterator)portletSession.getAttribute("i")).next()).equals(s)?"selected":" "%> >> 60 Days </option>
</select>
I tried using begin end but did not work out. Please help me out.
Regards
Upvotes: 0
Views: 73
Reputation: 488
end="<%= al.size()-2 %>"
the last element you want should be al.size()-2, according to array's index
Upvotes: 1