jQuery in Action, 2nd edition*
The moose likes JSP and the fly likes JSTL's EL.  Problem iterating over arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL Watch "JSTL New topic
Author

JSTL's EL. Problem iterating over arraylist

starrman777
Greenhorn

Joined: Mar 23, 2005
Posts: 6
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

Joined: Jan 10, 2002
Posts: 61766
    
  67

Which forEach is causing the problem?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
starrman777
Greenhorn

Joined: Mar 23, 2005
Posts: 6
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

Joined: Mar 23, 2005
Posts: 6
I guess the JSTL symbol got translated into an emoticon...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

The 'disable smilies' checkbox will prevent emoticon translation.

And how about posting your findings for anyone that might be having a similar issue?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL's EL. Problem iterating over arraylist