tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "petra staub" <cal...@hotmail.com>
Subject Re: Hashtable/Map access
Date Sat, 03 Aug 2002 14:22:05 GMT
great, and just another question to this:

how to do, if the key is a variable, say

color="blue" and now i want to do the
same again? how can i make the expression
first disolve the variable color to "blue"

color = "blue"
${MyMap.color}  -->  sky


thanks again!


>From: Shawn Bayern <bayern@essentially.net>
>Reply-To: "Tag Libraries Users List" <taglibs-user@jakarta.apache.org>
>To: Tag Libraries Users List <taglibs-user@jakarta.apache.org>
>Subject: Re: Hashtable/Map access
>Date: Sat, 3 Aug 2002 09:42:32 -0400 (EDT)
>
>On Sat, 3 Aug 2002, petra staub wrote:
>
> > Hi,
> >
> > I have a map/hashtable like:
> > {
> >   blue => sky
> >   green => frog
> >   red => ball
> >   yellow => sun
> > }
> >
> > I understand that using the <c:forEach> tag I
> > can iterate through the collection and access
> > every element with key and value.
> >
> > But how can I directly access the value of an
> > entry if I know the key?
> >
> > I tried something like MyMap.green, but this
> > seems not to be the way to do this, isnt?
>
>Yes, suppose that this map is stored in the scoped variable 'MyMap'.  The
>expression
>
>   ${MyMap.blue}
>
>will yield 'sky'.  If you want to iterate, consider the following example:
>
>  <c:forEach items="${MyMap}" var="entry">
>   key:   <c:out value="${entry.key}" />
>   value: <c:out value="${entry.value}" />
>  </c:forEach>
>
>Hope that helps,
>
>--
>Shawn Bayern
>"JSTL in Action"   http://www.jstlbook.com
>
>
>--
>To unsubscribe, e-mail:   
><mailto:taglibs-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: 
><mailto:taglibs-user-help@jakarta.apache.org>




_________________________________________________________________
Senden und empfangen Sie MSN Hotmail ├╝ber Ihren PocketPC: 
http://pocketpc.msn.de


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message