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's EL. Problem iterating over arraylist

 
starrman777
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am passing a ViewBean into a JSP page.
The ViewBean Contains a Map
The Key for the Map is a String
The Value for the Map is an ArrayList of Car objects

The viewBean is accessed using useBean.
<jsp:useBean id="viewBean"
class="com.whatever.MyViewBean"
scope="request" />

<c:forEach var="mapEntry" items="${viewBean.map}">
<c:set var="theKey" value="${mapEntry.key}" />
<c:set var="anArrayList" value="${mapEntry.value}" />

<c:forEach var="car" items="${anArrayList}" >
.
.
.
</c:forEach>
</c:forEach>

I am receiving an exception at this point: "javax.servlet.ServletException: Don't know how to iterate over supplied "items" in <forEach>"

I believe that the problem is the "anArrayList" and that it doesn't know that it is an ArrayList that can be iterated over.

Any Ideas what the problem is???
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which forEach is causing the problem?
 
starrman777
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I posted this question on another forum and the advice that I received was to find out what class the the Map's value actually is by doing this:

<c ut value="${anArrayList.class.name}"/>

Here is the post at the other forum
http://forum.java.sun.com/thread.jspa?threadID=633265&tstart=0

I tried that and figured out what to do from there.
Thanks!
 
starrman777
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess the JSTL symbol got translated into an emoticon...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 'disable smilies' checkbox will prevent emoticon translation.

And how about posting your findings for anyone that might be having a similar issue?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic