Am 09.10.2011 14:02, schrieb Antonio Petrelli:
2011/10/8 Kai<[email protected]>
<c:forEach var="i" begin="1" end="10" step="1">
...
The problem ist:
The EL-expression ${i} does not pick up the variable from the page-scope!
If I push the variable to request-scope with an<c:set var="i" value="${i}"
scope="request"/> inside the<c:forEach>-loop, everything works fine. But
that would polute the "global namespace" and might therefore lead to other
hard to find errors later on. Besides, using the EL-expression would be
pretty pointless than, because the variable is visible in the nested
definition anyway.
Am I missing something, is this a bug, or why is it not possible to pick up
variables from page-scope via EL-expressions in definitions?
You're missing how the "var" attribute works:
http://download.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/c/forEach.html
At the "var" attribute I read:
<snip>
Name of the exported scoped variable for the current item of the iteration.
This scoped variable has nested visibility. Its type depends on the object
of the underlying collection.
</snip>
So it's got nested visibility, not page.
You are right, I missed that one.
Thank you for your help so far :)
But unfortunatly, it's not the only problem.
I already tried to push the forEach-variable to page-scop with
<c:set var="i" value="${i}" scope="page"/>
But that does not help either!
The EL-Expression in the definition only picks it up, if I push the
variable to request-scope with
<c:set var="i" value="${i}" scope="request"/>
(I double-checked, that the variable is really picked up by the
EL-Expression and is not only visible inside the other template, because
it was pushed inside request-scope. When in request-scope, the
expression picks up the variable, when in page-scope not!)
Greetings Kai