Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL

 
deepa raj
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."
 
Anand Bhatt
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?
 
Amruth Puppala
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic