If I have some object stored as a request attribute named myObject I can find out its type in JSP EL like this:
${myObject['class']}
But if I have a java.util.Map
stored as a request attribute myMap, and I put this in my page...
${myMap['class']}
...the Map is searched for an entry whose key is "class". This makes sense, otherwise we could never retrieve anything in EL from a Map with a key of "class".
So how do I display the type of my Map in an EL statement?
(And most of you will want to ask me: "Why do you care?". Well, today I was working on a train with no Internet connection and I had to iterate a java.util.HashMap
in a page, and I completely forgot how to do that. So, not being able to Google or SO it, I decided to find out what the type was (I knew it wasn't an actual java.util.HashMap, Tomcat turns it into something else) so I could go rummaging around in the Tomcat jar files and see what methods it exposed and maybe figure it out myself. Well, I couldn't find out the type via EL. I resorted to embedded Java inside <% %>
tags. But it has been bothering me all day that I coulnd't find out with EL alone. So, that's why I care. It's eating me up.)