Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jstl foreach iterate over arraylist containing map object using paramvalues

 
Angel Smith
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic