jQuery in Action, 2nd edition*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes how to use scope in target version of c:set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "how to use scope in target version of c:set" Watch "how to use scope in target version of c:set" New topic
Author

how to use scope in target version of c:set

Praveen Sharma
Ranch Hand

Joined: Jul 31, 2008
Posts: 129
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


SCJP 80% SCWCD 89%
Lakshmi Narayanan
Ranch Hand

Joined: Apr 29, 2008
Posts: 58
I believer only var has Scope Attribute not Target.


Thanks<br />Lakshmi<br />SCJP 1.4 - 90%<br />SCWCD 5 - 89%
Atul Samnerkar
Ranch Hand

Joined: Sep 20, 2003
Posts: 44
Refer to https://issues.apache.org/bugzilla/show_bug.cgi?id=15703
Seems this is known bug.


Cheers...
Atul Samnerkar
Praveen Sharma
Ranch Hand

Joined: Jul 31, 2008
Posts: 129
So that means, I can use target version of c:set only when the object is stored in the page scope ?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.



[My Blog]
All roads lead to JavaRanch
Praveen Sharma
Ranch Hand

Joined: Jul 31, 2008
Posts: 129
Got it !! Thanks Christophe
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to use scope in target version of c:set