java - JSTL: How to get previous and next iteration elements of Map? -



java - JSTL: How to get previous and next iteration elements of Map? -

i have treemap in servlet , populate follows:

map<integer, clocktrans> ctsdictionary = new treemap<integer, clocktrans>(); clocktrans cts = null; (int = 0; < ctsarr.length; i++) { cts = ctsarr[i]; ctsdictionary.put(i, cts); }

then in jsp, need display value of previous, current , next/upcoming iteration values. simplicity, in code below, removed checks first , lastly row avoid index out of bounds errors. main concern part utilize "status.index+1" read ahead next iteration value not working. what's proper syntax read previous , next values?

<c:foreach items="${ctsdictionary}" var="cts" varstatus="status"> <tr> <td align="center"> prev: <c:out value='${cts[status.index-1].value.clock_no}'/> curr: <c:out value='${cts.value.clock_no}'/> next: <c:out value='${cts[status.index+1].value.clock_no}'/> </td> </tr> </c:foreach>

i haven't used before, guess need utilize ${ctsdictionary[status.index-1] instead of ${cts[status.index-1] because cts current item.

java javascript map jstl el

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -