This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes JSTL foreach question (vector in a hashmap) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL foreach question (vector in a hashmap)" Watch "JSTL foreach question (vector in a hashmap)" New topic
Author

JSTL foreach question (vector in a hashmap)

Seamus Loftus
Greenhorn

Joined: Mar 29, 2006
Posts: 1
Hello all,
I am trying to get a nested vector out of a hashmap. The problem is that the JSTL line returns a object and not the vector I need. Is there a way to convert this?

Here is a code snippet:
<c:forEach var='hashitem' items='${queryFormBean.hash}'>
<c:set var="hashsubitem" value="${hashitem.key}"/>
<c:forEach var='vectval' items='${hashsubitem}'>
- <c ut value='${vectval}'/>, <c ut value='${hashitem.value}'/><BR>
</c:forEach>
</c:forEach>

Later,
Seamus
[ April 07, 2006: Message edited by: Seamus Loftus ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Originally posted by Seamus Loftus:
The problem is that the JSTL line returns a object and not the vector I need.


The EL is interpretive. It will "return" whatever the object really is.

Secondly, in the following lines;


<c:set var="hashsubitem" value="${hashitem.key}"/>
<c:forEach var='vectval' items='${hashsubitem}'>


you are setting hashsubitem from the key of the Map.Entry instance and then attempting to iterate over that. Is the vector really the key of your Map? Or did you mean to iterate over the value?

If so, the line should be:



Finally, when posting code, please be sure to check the 'disable smilies' checkbox so that your <c:out> tags look less surprised!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Don't get me started about those stupid light bulbs.
 
subject: JSTL foreach question (vector in a hashmap)