Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is target in c:target??

 
trivikram Kumar
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pals,

Could someone explain me whats the difference between a target and an id in tag files.If someone worked on any example ,could you please forward that to me??I am getting confused ...here.

I just know that target can take only an object...so does it take an attribute???

Also..i bought the enthuware software but its getting stuck at the license page...i need help regarding how it can be installed..

Thanks in bunch..
Javainn
 
trivikram Kumar
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone please look into this???
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you referring to the target attribute in the <c:set> tag? If so, then this might help...

When using <c:set>, the "target" must evaluate to an actual object. The HF book warns people that they should not just use the String literal that represents the name of a scoped attribute.... but IMHO they could be a little clearer. Take the following as an example of both the right and wrong way to use the target attribute (assume foo.Person is a bean that has a name property):
The difference between the correct and wrong examples is that in the correct examples, "person" is evaluated to the actual foo.Person object. This means you must use EL, scripting, or <jsp:attribute> in the "target". Hope that helps!
[ May 04, 2005: Message edited by: Paul Bourdeaux ]
 
trivikram Kumar
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul:

That was really helpful..
Is that the only difference between <c:set var=="".../> and <c:set target=:""..../>
If yes thats fine..else could you please elaborate on this...

Thanks,
Javainn
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is the only syntax difference between <c:set var=...> and <c:set target=...>. They are used similarily, but you have to keep the different uses in mind.

You can only use <c:set var=...> with attributes. If an attribute named by "var" does not exist in any scope, one will be created in page scope.

You can only use <c:set target=...> with a bean or a Map. If you try to use target with something other than a bean or a Map, you will get an exception.
 
trivikram Kumar
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul...

You cleared my doubt and made my mind free...
Thanks a lot..

Javainn
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic