• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JSTL's EL. Problem iterating over arraylist

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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???
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which forEach is causing the problem?
 
starrman777
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess the JSTL symbol got translated into an emoticon...
 
Bear Bibeault
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic