This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread 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


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: 63208
    
  69

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]
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: JSTL foreach question (vector in a hashmap)
 
jQuery in Action, 3rd edition