aspose file tools*
The moose likes JSP and the fly likes Jstl foreach iterate over arraylist containing map object using paramvalues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Jstl foreach iterate over arraylist containing map object using paramvalues" Watch "Jstl foreach iterate over arraylist containing map object using paramvalues" New topic
Author

Jstl foreach iterate over arraylist containing map object using paramvalues

Angel Smith
Greenhorn

Joined: Oct 01, 2008
Posts: 1
Hi following is my java code



I want to display this on my view using jstl

To iterate over a plain arraylist containing Integers , the following works


However my arraylist contains hashmaps and I have tried a couple of things including the following



Nothing seems to work!!.. Have spent a lot of hours searching for an answer...but the data doesnt show up..

How would I iterate over a hashmap inside a list using paramvalues as for some reason , thats the only method that seems to work??

I am using jstl1.2 and tomcat 6.0 to deploy the application

Thanks for all your help!!
[ October 01, 2008: Message edited by: Angel Smith ]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi,

just run below one in sample jsp..you may get some idea..




scriptlet part you have to do in servlet...for example i put scriptlet

Hope This Helps
Chris Baty
Ranch Hand

Joined: Nov 23, 2008
Posts: 30
I'm working on this too.
<c:forEach var="row" varStatus="status" items="${name.rows}">
<c:set var="count" value="${row.items}"/>
<jsp:setProperty name="sh" property="uName" value="${row.uname}" />
<jsp:setProperty name="sh" property="city" value="${row.city}" />
.
.
<%Map sale = new HashMap();
String myID = id.getUsername();
float dist = (float)zp.getCalc(lat1,long1,lat2,long2,'M');
sh.setDistance(dist);
sale.put(sh,count);
tsSale.add(sale);
count++;%>
</c:forEach>
<% pageContext.setAttribute("sales",tsSale); %>
<c:forEach var="row" varStatus="status" items="${sale}">
<c:set var="name" value="${row.uName}" scope="request"/>
.
.
I'm getting nothing out. I thought that I was filling my Arraylist? What am I doing wrong?
Thaanks.
Chris
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61774
    
  67

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .

Also, in future posts, please be sure to start new topics with your own questions rather than tacking your own questions onto a similar topic.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jstl foreach iterate over arraylist containing map object using paramvalues