Is it possible to access the JSTL forEach variable through code from a loop?
<c:forEach items="${elements}" var="element"> <% element.someMethod(); %> </c:forEach>
Well, I believe that the "element" is stored in the context of the page.
<c:forEach items="${elements}" var="element"> <% ((Element) pageContext.getAttribute("elements")).someMethod(); %> </c:forEach>
Change after correction example:
Yes you can access varinsidec:forEach
var
c:forEach
Here is an example:
<c:forEach items="${elements}" var="element"> ${((Element)element).someMethod()} </c:forEach>
See c: forEach in the JSTL documentation.