• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

setting hashmap value using jstl

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a structure like this...
list -> hashmap

Now I am able to display hashmap values in different textboxes using JSTL but I want to have my original hashmap values also.

Here is how I am displaying my original hashmap.
<c:forEach items="${List[1].termAmtMap}" var="th2Obj">
<html:text property="${th2Obj.key}" value="${th2Obj.value}" size="7"/>%
(<c:out value="${th2Obj.key}" /> Y)
</c:forEach>

Now I am tring to keep original values also using <c:set> but it is not workin, it says classcastexception and that is becauase Key is integer while value I am setting is String.
<c:set target="oriList[1].termAmtMap" property = "oriList[1].termAmtMap.key" value="${List[1].termAmtMap.key}"></c:set>

Please help with this issue.Thanks in advance.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My advice: don't do this in JSTL, do it in java code.
JSTL is great for displaying contents of maps.
It is not particularly useful with manipulating maps.

Said java code should of course reside in a servlet/bean, not on the JSP page.

 
Hd Desai
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks stephan for reply.

I agree completely with your point, but my problem is this is exising application in struts1.2 and I am now allowed to change any existing implementation :-(
 
Sheriff
Posts: 67747
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
Look at the docs for <c:set>. Particularly the target and property attributes.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic