Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to iterate over all attributes with pure tags and EL?

 
r vertet
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1784
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Any tricks available to iterate over the different scopes (page, request, appl, session) via jslt?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65226
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that not what Tim just gave you the code for?
 
r vertet
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, this iterates over the attributes in 1 (!) scope. What I mean is something like this:



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65226
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no Map that aggregates all the scopes. You need to iterate over each scope individually.
 
r vertet
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic