• 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

how to use scope in target version of c:set

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believer only var has Scope Attribute not Target.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it !! Thanks Christophe
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic