tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric.Le...@swissinfo.ch
Subject JSTL and HashMap: How does it work?
Date Wed, 09 Oct 2002 18:02:36 GMT
Hi all

According to the documentation, it's possible to get data from a HashMap in
JSTL. Unfortunately, it doesn't really work for me...

Here's the deal: A stock has a collection of charts, thus:

stock.numberOfCharts = <c:out value="${stock.numberOfCharts}"/><br>
stock.charts = <c:out value="${stock.charts}"/>
<c:forEach var="chart" items="${stock.charts}">
	<br>-> chart = <c:out value="${chart}"/>
</c:forEach>

results in

stock.numberOfCharts = 9
stock.charts = {1M=ch.xobix.contentgroup.controller.ImageWrapper@f6ae1c,
2M=ch.xobix.contentgroup.controller.ImageWrapper@20d6b7,
3M=ch.xobix.contentgroup.controller.ImageWrapper@f08d0f,
6M=ch.xobix.contentgroup.controller.ImageWrapper@bcfa38,
1Y=ch.xobix.contentgroup.controller.ImageWrapper@cfaf6e,
2Y=ch.xobix.contentgroup.controller.ImageWrapper@6989e,
3Y=ch.xobix.contentgroup.controller.ImageWrapper@dd7a7,
5Y=ch.xobix.contentgroup.controller.ImageWrapper@c94114,
YTD=ch.xobix.contentgroup.controller.ImageWrapper@cf9bf0} 
-> chart = 1M=ch.xobix.contentgroup.controller.ImageWrapper@f6ae1c 
-> chart = 2M=ch.xobix.contentgroup.controller.ImageWrapper@20d6b7 
-> chart = 3M=ch.xobix.contentgroup.controller.ImageWrapper@f08d0f 
-> chart = 6M=ch.xobix.contentgroup.controller.ImageWrapper@bcfa38 
-> chart = 1Y=ch.xobix.contentgroup.controller.ImageWrapper@cfaf6e 
-> chart = 2Y=ch.xobix.contentgroup.controller.ImageWrapper@6989e 
-> chart = 3Y=ch.xobix.contentgroup.controller.ImageWrapper@dd7a7 
-> chart = 5Y=ch.xobix.contentgroup.controller.ImageWrapper@c94114 
-> chart = YTD=ch.xobix.contentgroup.controller.ImageWrapper@cf9bf0

which is fine. However, how can I address one entry?
If I try

chart = <c:out value="${stock.charts["1M"]}"/>

I get

javax.servlet.ServletException: /jsp/financialdata/show.jsp(33,40) Attribute
1M has no value

By the way, my getCharts() returns a LinkedHashMap (I wanted the same
sequence as when I inserted the objects). Theoretically, shouldn't I be able
to traverse it like e.g. an ArrayList?

chart[0] = <c:out value="${stock.charts[0]}"/>

doesn't give me anything, though...


Best regards,
Eric


--
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