tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (David M. Karr)
Subject Re: Getting values from a Map in JSTL-EL
Date Sat, 23 Nov 2002 06:19:11 GMT
>>>>> "Affan" == Affan Qureshi <> writes:

    Affan> I have two questions. How to get values if my bean has a method that returns
    Affan> a Map? I have a bean with getValues() method that returns a Map.
    Affan> I have tried
    Affan> <c:out value="${specs.values.paramId}" />

    Affan> <c:out value="${specs.values[paramId]}" />

    Affan> <c:out value="${}" />

    Affan> But I get the following error:
    Affan> Unable to find a value for "map" in object of class
    Affan> "java.util.HashMap$Values" using operator "."'  (correspondingly)

Did you try all three of these at the same time?  The last one is obviously
broken, which is why you got the error.

The second one and the first one are actually slightly different.  The first
one looks for a key of "paramId" in the map, and the second one looks in the
map with a key that is STORED IN the scoped attribute named "paramId".  If you
wanted to change the second one to do the same thing as the first, change it

  <c:out value='${specs.values["paramId"]}' />

    Affan> Also my bean also has a method that takes a String and returns the value
    Affan> Object from the map. Its signature is:
    Affan> public Object getValue(String key)

    Affan> How do I use this method using EL?

You can't.  This kind of expression (called "mapped properties") is supported
by the Jakarta Commons BeanUtils package, but not with the JSTL.

David M. Karr          ; Java/J2EE/XML/Unix/C++   ; SCJP

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message