Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use scope in target version of c:set

 
Praveen Sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,using the target version of c:set how can I set the value of a property of a bean which is stored in request scope ?

In my servlet I have the following code :
Employee emp = new Employee(144142,"John"); //new Employee(Id,name)
request.setAttribute("emp", emp);

In my JSP I am trying to do this :
<c:set target="${emp}" property="id" value="13345" scope="request" />
<c:set target="${emp}" property="name" value="Tom" scope="request" />

But I get the following error in TomCat :
Illegal scope attribute without var in "c:set" tag
 
Lakshmi Narayanan
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believer only var has Scope Attribute not Target.
 
Atul Samnerkar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer to https://issues.apache.org/bugzilla/show_bug.cgi?id=15703
Seems this is known bug.


Cheers...
Atul Samnerkar
 
Praveen Sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So that means, I can use target version of c:set only when the object is stored in the page scope ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems this is known bug.

No, this bug is about fmt:setLocale. The c:set tag does not allow a scope when the target attribute is used. Why would you need a scope, as you are passing the object in the target ? With a bean, you'll specify the scope in the useBean tag.

 
Praveen Sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it !! Thanks Christophe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic