Originally posted by Eric Savage:
Two questions.
First, in JSTL, how does one get the size of a map/collection/etc. This seems such a common thing that I'm sure it must be somewhere but I can't find it.
Actually, JSTL 1.0 doesn't provide this; JSTL 1.1 will most likely introduce a function to support it.
In the meantime, you can either (a) provide a wrapper class with methods like getSize() and getArray(), or (b) simply loop over the array and compute its size with <c:forEach>'s 'varStatus' attribute. However, the latter option isn't particularly efficient.
User.getTickets() returns a Hashtable. I also tried extending Hashtable and adding the following:
A wrapper class will work in general, but an object's nature as a Map occludes its nature as a JavaBean for JSTL's purposes. That is, when an object is a Map, only its Map elements -- not its JavaBean properties -- will be returned.
[/QB]
Second, how does one reference a static property in JSTL. Something like the following:
[/QB]
[/QB]
The EL is intended only to refer to instance variables, not static data. You could expose a bean that returns the right values for particular constants, or use context-initialization parameters defined in web.xml.