| Author |
How to iterate over all attributes with pure tags and EL?
|
r vertet
Greenhorn
Joined: Apr 10, 2012
Posts: 17
|
|
Hi,
is it possible to iterate over all pagecontext-attributes using pure taglibs & el?
Like:
If I try this I get the error: Cannot find bean org.apache.catalina.core.ApplicationHttpRequest$AttributeNamesEnumerator@9daa17 in any scope
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1005
|
|
I'd go with the JSTL loop rather than the struts loop.
Struts actually deprecated their loop tag in favour of the JSTL one.
Struts and JSTL tags work together without a problem.
EL also makes available some implicit variables: pageScope, requestScope, sessionScope, applicationScope which are maps of the attributes in each scope.
That is easier than using the methods on the request object.
Here is a JSP snippet that will print out all the variables in page scope plus their value
|
 |
r vertet
Greenhorn
Joined: Apr 10, 2012
Posts: 17
|
|
|
Thanks. Any tricks available to iterate over the different scopes (page, request, appl, session) via jslt?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56221
|
|
Is that not what Tim just gave you the code for?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
r vertet
Greenhorn
Joined: Apr 10, 2012
Posts: 17
|
|
No, this iterates over the attributes in 1 (!) scope. What I mean is something like this:
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56221
|
|
|
There is no Map that aggregates all the scopes. You need to iterate over each scope individually.
|
 |
r vertet
Greenhorn
Joined: Apr 10, 2012
Posts: 17
|
|
|
Ok, thanks.
|
 |
 |
|
|
subject: How to iterate over all attributes with pure tags and EL?
|
|
|