• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error in c:set tag

 
Paolo Metafune
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've a strange errore while using the <c:set> tag.
I'm trying to setting a new value in an element of a Map but when i execute the jsp i receive this error : javax.servlet.jsp.JspTagException: Invalid property in <set>: "first"

My tomcat version is : 5.0.19 and my jdk version is : 1.4.2_03

This is part of the code of my jsp:
************************************************+
<% Map m = new HashMap();
m.put("first","f");
%>
<c:set var="myMap" value="<%=m%>" scope="page" />
<c ut value="Map In Page scope: " />
<c ut value="<%=pageContext.getAttribute("myMap")%>" default=" Map not in page scope" />
<BR>
<c ut value="Class: " />
<c ut value="<%=pageContext.getAttribute("myMap").getClass()%>" default=" Map not in page scope" />
<BR>
<c ut value="New Value for the element with key = first: " />
<c:set value="firstVal" target="myMap" property="first" />
<c ut value="${pageScope.myMap.first}" />
***************************************
If i delete the last three instructions the code works fine and i can see the initial map entry displayed in the output page

Can anyone tell me what is wrong with my code ?

Thank you.
 
Sergey Tyulkin
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the target attribute must be used with ${}
So, your tag must look like
<c:set value="firstVal" target="${myMap}" property="first" />
 
Paolo Metafune
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Sergey, now it works.

Bye.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!