About Question enthuware.jwpv6.2.826 :

Moderator: admin

Post Reply
Ciprian Mihalache
Posts: 51
Joined: Wed Sep 28, 2011 12:14 pm
Contact:

About Question enthuware.jwpv6.2.826 :

Post by Ciprian Mihalache »

The second answer is
<jsp:setProperty name="acct2" property="address" value="${acct1.address}" />
But, in order to match the explanation I suppose it should have name="${acct2}", because the explanation states:
jsp:setProperty uses the "name" of the bean that has been created using jsp:useBean tag (the id value).So ${acct2} will not work here because ${acct2} is not the name of the bean but a reference to the bean itself.

Ciprian Mihalache
Posts: 51
Joined: Wed Sep 28, 2011 12:14 pm
Contact:

Re: About Question enthuware.jwpv6.2.826 :

Post by Ciprian Mihalache »

Sorry, now I saw it is correct, and the explanation refers to a hypothetical situation.
It is ok the way it is.

harsh.sahajwani
Posts: 13
Joined: Sun Jan 20, 2013 5:58 am
Contact:

Re: About Question enthuware.jwpv6.2.826 :

Post by harsh.sahajwani »

What I understand about jsp:getProperty is that it simply gets the value of a property from a bean and it simply prints its value to the JSP output. Is my understanding correct?

Is there any way by which we can use jsp:getProperty to get the value of a property of a bean and use it to set a property to another bean, using c:set or using jsp:setProperty? If yes, please provide examples of all possible ways.

admin
Site Admin
Posts: 10068
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.826 :

Post by admin »

No, there is no way to do that directly. For details, please see Section 5.2 and 5.3 of JSP 2.2 Specification.
If you like our products and services, please help us by posting your review here.

basamajoe
Posts: 21
Joined: Fri Apr 26, 2013 3:40 am
Contact:

Re: About Question enthuware.jwpv6.2.826 :

Post by basamajoe »

I can't see why answer
<c:set target="${acct2}"  property="address">
   <jsp:getProperty name="acct1" property="address" />
</c:set>
is incorrect

It is explained that it gets a String, but isn't the tag <jsp:getProperty name="acct1" property="address" /> getting a Adress object?

And if it is so, and c:set needs an Address object ?¿

Thanks in advance!

admin
Site Admin
Posts: 10068
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.826 :

Post by admin »

It doesn't return Address. As explained in the explanation, it returns a String by calling toString() on the address object. You might want to try it out with a test jsp.
Also, please see Section 5.3 of JSP spec:
JSP.5.3 <jsp:getProperty>
The <jsp:getProperty> action places the value of a bean instance property, converted to a String, into the implicit out object, from which the value can be displayed
as output.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 71 guests