This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL foreach question (vector in a hashmap)

 
Seamus Loftus
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic