You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by petra staub <ca...@hotmail.com> on 2002/08/03 15:39:51 UTC

Hashtable/Map access


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?

Can someone help me newbie?

Thanks!


_________________________________________________________________
Mit MSN Fotos können Sie kinderleicht Ihre Fotos ausdrucken und Freunden zur 
Verfügung stellen: http://photos.msn.de


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hashtable/Map access

Posted by anand <an...@columbus.rr.com>.
Shawn,

I have a connection string in the web.xml as follows:

<context-param>
  <param-name>
       javax.servlet.jsp.jstl.sql.dataSource
 </param-name>
 <paramvalue>

jdbc:microsoft:sqlserver://localhost:1433;SelectMethod=cursor;,com.microsoft
.jdbc.sqlserver.SQLServerDriver,ltd_user
 </param-value>
</context-param>

and my JSTL SQL have no problems getting the connection and executing the
commands.

But, I would like to use the JNDI datasource name 'ltd_ds' that was setup in
connection pool under my weblogic server.
You do talk about that it is possible to specifyJNDI datasource name in your
JSTl Book,
But there is no syntex or example given in  book.

I tried few of my own, but I could not get it working. Any thoughts on
this..

Thanks again,

Dave A





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Hashtable/Map access

Posted by Shawn Bayern <ba...@essentially.net>.
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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>