• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

JSTL

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please explain the below saying with example.

"The �target� is for putting in an expression that resolves to the Real Object. If you put in a String literal that represents the �id� name of the bean or Map, it won�t work. In other words, �target� is not for the attribute name of the bean or Map�it�s for the actual attribute object."
 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The �target� is for putting in an expression that resolves to the Real Object. If you put in a String literal that represents the �id� name of the bean or Map, it won�t work. In other words, �target� is not for the attribute name of the bean or Map�it�s for the actual attribute object."



say like in your servlet you set like this:
Let say Myobject is bean defined by you.Now,
Myobject myObject = new Myobject();
request.setAttribute("myName",myObject);

Now target must be something that resolves to real object that is "myObject ". no the string litral that is "myName",as it is a attribute name.

Is this clear somwewhat?
 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Example <c:set value=�hyderabad� target=�person� property=�address�/>

in the ablove example target is the person should be Object. means it is trying to set the address property of person.

if we see it as programatically

person.setAddress("hyderabad");

so here person should be Object . If it is not object it throws exception.
Same this for the statement you reffering will apply.
 
deepa raj
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.

My understanding is ,

say Bean.java is class having some getter/setter methods.

Bean bObject = new Bean();

request.setAttribute("bean",bObject);

Map mObject = new HashMap();

request.setAttribute("map",mObject);

while using c:set we have to use target as bObject or mObject.

while using jsp:useBean we should use bean

while using EL we should use ${bean.property} or ${map.key}

am i correct??
 
deepa raj
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello anand, any comments about my understanding??
 
Anand Bhatt
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct.
 
On my planet I'm considered quite beautiful. Thanks to the poetry in this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic