aspose file tools*
The moose likes JSP and the fly likes JSTL printing issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL printing issue" Watch "JSTL printing issue" New topic
Author

JSTL printing issue

Sripathi Krishnamurthy
Ranch Hand

Joined: Mar 07, 2005
Posts: 232
Hi,
I have this problem..

In a JAVA class I have the below code


In a JSP, I have written a JSTL which is written this way,


So basically what I have is, a Hashmap which has String as a key and an ArrayList object as a value.
When I try to run this, I get the error cannot run forEach for "items".
What part of code am I not writing correctly? Please help.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

hai
culprit:
request.setAttribute("param",map);

change your name from param to param1 or something else..because param is one of the implicit object in EL...more over for:Each items should be collection or array

Hope THis Helps
Sripathi Krishnamurthy
Ranch Hand

Joined: Mar 07, 2005
Posts: 232
Originally posted by seetharaman venkatasamy:
hai
culprit:
request.setAttribute("param",map);

change your name from param to param1 or something else..because param is one of the implicit object in EL...more over for:Each items should be collection or array

Hope THis Helps


The one I have given above is just an example. I havent used param as I have given there. The variable names that I am using in my application is entirely different. For this example, you can assume it as "param1" as you have indicated.
Thanks
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

insteadof <cut value="${users}"/> you just use

${uesrs}...and let me know
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3950
    
  17

When you iterate over a map you are iterating over the entry set, not the map directly. This means that each value returned by the outer loop is a MapEntry, not an ArrayList. The MapEntry would have a method getValue() which would return the ArrayList to use for the inner loop. Example:


Steve
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks luke
Sripathi Krishnamurthy
Ranch Hand

Joined: Mar 07, 2005
Posts: 232
Originally posted by Steve Luke:
When you iterate over a map you are iterating over the entry set, not the map directly. This means that each value returned by the outer loop is a MapEntry, not an ArrayList. The MapEntry would have a method getValue() which would return the ArrayList to use for the inner loop. Example:


Thank you very much. It is working fine now.
Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL printing issue
 
Similar Threads
key from HashMap
Scriptlet vs JSTL
Jstl foreach iterate over arraylist containing map object using paramvalues
Iterating through local List using JSTL
Iterating List of Maps through c:foreach