• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting hashmap value using jstl

 
Hd Desai
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • 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.
 
Stefan Evans
Bartender
Posts: 1692
10
  • Mark post as helpful
  • send pies
  • 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
  • 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 :-(
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the docs for <c:set>. Particularly the target and property attributes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic