aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question on cset Target Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question on cset Target" Watch "Question on cset Target" New topic
Author

Question on cset Target

Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
For <c:set target="${PetMap}" property="dogName" value="Clover"/> syntax on page 456 in HFSJ ,it says that
The target must evaluate to the OBJECT! You don't type in the string "id" name of the bean or Map attribute! With the "target" attribute ,you do not type in the String literal that represents the name under which the attribute was bound to the page,scope,etc. No,the "target" attribute needs a value that resolves to the REAL THING.


But I tried following example ,for "target" attribute I had to give name to which attribute was bound



Then,why in HFSJ it is saying that With the "target" attribute ,you do not type in the String literal that represents the name under which the attribute was bound to the page,scope,etc ?

Thanks
Veena


SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Bob Wheeler
Ranch Hand

Joined: Apr 24, 2009
Posts: 317
Veena Pointi wrote:
Then,why in HFSJ it is saying that With the "target" attribute ,you do not type in the String literal that represents the name under which the attribute was bound to the page,scope,etc ?


Hi Veena,

You didn't use a String literal. Instead you used an EL expression (${PetMap}), which evaluates to the "real thing", the object (in your example the Map petMaps).
The following doesn't work (notice: PetMap is now a String literal):


For the c:set var property a String literal works:


I hope I could help.
cheers
Bob>


SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
Sagar Vyas
Greenhorn

Joined: Feb 17, 2013
Posts: 10


Hi Veena,

You didn't use a String literal. Instead you used an EL expression (${PetMap}), which evaluates to the "real thing", the object (in your example the Map petMaps).
The following doesn't work (notice: PetMap is now a String literal):


For the c:set var property a String literal works:




I hope I could help.
cheers
Bob>


Hi Bob,

I did not get this , can you please explain How to get what veena wants ?

I mean How to point real object what exactly mean of this ? If i say req.setAttribute("Test",Test);
consider a "Test" is something like MyBean Test = new MyBean();

and if I am doing something like this <c:set target="${Test}" pr.... /> Will I able to set property of Test ? If Not then Y not ?

Thanks,
Sagar Vyas


Sagar Vyas
"More Sharing and More Learning"
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1529
    
  22

Hi Sagar,

You are replying to a thread that has been dead for three years (!). I doubt that Bob will reply.

I mean How to point real object what exactly mean of this ? If i say req.setAttribute("Test",Test);
consider a "Test" is something like MyBean Test = new MyBean();
and if I am doing something like this <c:set target="${Test}" pr.... /> Will I able to set property of Test ? If Not then Y not ?

Yes you will be able to set that property.

Veena was confused by the phrase: "With the "target" attribute ,you do not type in the String literal that represents the name under which the attribute was bound to the page,scope,etc"

So you don't do

but

Does it make sense now?

Regards,
Frits
Sagar Vyas
Greenhorn

Joined: Feb 17, 2013
Posts: 10
Hi Frist,

First of all Thank you for your reply.

And ya "Thread can never be dead", lots of people may looking at this thread to resolve her/his problem, instead of creating new thread I thought this would be the better approach to ask, I was expecting answer from one of the Java Guru like you only.

I have one more doubt,please help me to understand ?

I read somewhere like
<c:set target=""> must point to a real object and not the name of object as it was with <jsp:useBean> action what I understood from this is its like as we are using <jsp:useBean>'s id attribute it is a same thing ?
correct me if I misunderstood it ?

Thanks,
Sagar Vyas
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1529
    
  22

Hi Sagar Vyas,

And ya "Thread can never be dead", lots of people may looking at this thread to resolve her/his problem, instead of creating new thread I thought this would be the better approach to ask, I was expecting answer from one of the Java Guru like you only.

No problem, I was just surprised to see it being raised from the dead

<c:set target=""> must point to a real object and not the name of object as it was with <jsp:useBean> action what I understood from this is its like as we are using <jsp:useBean>'s id attribute it is a same thing ?

With <jsp:useBean> you either create (instantiate) a real object or you point to one that is already available in one of the contexts (page, request, session, application).

In other words you can point to a object that has been created or pointed at with a <jsp:useBean>:

A simple Employee class

And the part in a JSP where you will create an Employee in the "page" context

When you run this example you will see the following output:
Frits 10 Frits 2

Regards,
Frits
Sagar Vyas
Greenhorn

Joined: Feb 17, 2013
Posts: 10
Frits Walraven wrote:Hi Sagar Vyas,

<c:set target=""> must point to a real object and not the name of object as it was with <jsp:useBean> action what I understood from this is its like as we are using <jsp:useBean>'s id attribute it is a same thing ?

With <jsp:useBean> you either create (instantiate) a real object or you point to one that is already available in one of the contexts (page, request, session, application).

In other words you can point to a object that has been created or pointed at with a <jsp:useBean>:

Regards,
Frits


Hey Frits,

That what I was expecting , Thanks for neat clarifications. (And also Thanks for given life to this dead thread ;) )

See you later.

Thanks,
Sagar Vyas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on cset Target
 
Similar Threads
c:set target doubt
doubt in <c:set> from HFSJ
problem in understanding jstl set tag
c:set target="${...}" or target="..."
cset Property doubt??