Page 1 of 1

About Question enthuware.jwpv6.2.826 :

Posted: Thu Feb 02, 2012 12:26 pm
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.

Re: About Question enthuware.jwpv6.2.826 :

Posted: Thu Feb 02, 2012 12:32 pm
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.

Re: About Question enthuware.jwpv6.2.826 :

Posted: Tue Jan 22, 2013 1:07 pm
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.

Re: About Question enthuware.jwpv6.2.826 :

Posted: Tue Jan 22, 2013 2:41 pm
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.

Re: About Question enthuware.jwpv6.2.826 :

Posted: Sun Nov 03, 2013 8:33 am
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!

Re: About Question enthuware.jwpv6.2.826 :

Posted: Sun Nov 03, 2013 5:25 pm
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.