Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Jstl foreach iterate over arraylist containing map object using paramvalues

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67537
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
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.
 
This tiny ad is suggesting that maybe she should go play in traffic.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic