Is it possible to access JSTL's forEach variable via code from within the loop?
<c:forEach items="${elements}" var="element">
<% element.someMethod(); %>
</c:forEach>
Well, I believe "element" is stored in the page context.
<c:forEach items="${elements}" var="element">
<% ((Element) pageContext.getAttribute("elements")).someMethod(); %>
</c:forEach>
Edit following the correction of the example:
Yes, it is possible to access the var inside the c:forEach
Here's an example:
<c:forEach items="${elements}" var="element">
${((Element)element).someMethod()}
</c:forEach>
See c:forEach in the JSTL Documentation.