• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem iterating over implicit EL header object

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On my workstation which is running Tomcat 5.5 (Java 1.5 JVM) the following code works and prints out the HTTP headers:



However, when I copy it over to our server which is running Tomcat 6 (1.6 JVM) I get the following output:



Why is this? Any help/advice much appreciated!

Stephen
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Either Tomcat changed the toString() method on their implementation class, or they changed the class itself.

I haven't tried it myself, but you should be able to retrieve the key and value properties of the entry (rather than relying upon the toString() of the entry itself).
 
Ste Graham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! I have now:



, and this works. For some reason I didn't know you could reference the names and values like this! ops:

Stephen
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EL leans on getters/setters. ${foo.bar.waa} roughly translates to "foo.getBar().getWaa()".

java.util.Map.Entry has getKey() and getValue() methods.

[Edit: not-so-nice portion removed]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What may not have been obvious is that the iteration elements implement Map.Entry.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
${header} refers to a java.util.Map.
 
reply
    Bookmark Topic Watch Topic
  • New Topic