• Post Reply Bookmark Topic Watch Topic
  • New Topic

c:set with target

 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HFSJ on page 457 its written:

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


I simply cannot understand what is meant by the word "real attribute object" here, and "id name of the bean". are they not the same thing?? can anyone explain??

I have created a jsp to test it:



here i have used the id "address" in the target and it is working fine.

same is the case when i tried with a map. i set an attribute using pageContext.setAttribute("myMap",tmap) and using c:set i put target='${myMap}' it worked well . What is the writer trying to explain???
 
Win Siu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means if you do:

<c:set target="address" .... >

it would not work even if "address" is a bean in request attribute. It must be a real time expression like EL or expression script.

This is in contrast with <c:set var="name" value="Peter" ...> where "name" is an attribute.

 
saima kanwal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, i got it now.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!