This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes bean setProperty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "bean setProperty" Watch "bean setProperty" New topic
Author

bean setProperty

Marie Mazerolle
Ranch Hand

Joined: Oct 01, 2002
Posts: 81
Hi,
Here's a question from my book("Professional SCWCD certication"):
Consider the following JavaBean:

Consider the following JSP code from User.jsp:
<jsp:userBean id="usr" scope="request" class="UserBean" />
<jsp:setProperty name="usr" property="*" />
<jsp:setProperty name="usr" property="department" />
<jsp:setProperty name="usr" property="department" param="dept"/>
<jsp:setProperty name="usr" property="department" value="Sales"/>
<jsp:setProperty name="usr" property="department" />
What will the output as the result of requesting the JSP page above via the following hyperlink: http://myserver.com/myApp/User.jsp?dept="IT"&department="Finance"
Select one correct answer:
a. FinanceITSales
b. Finance
c. IT
d. Sales
e. Nothing will be returned
"The correct answer is d, as the <jsp:setProperty> tabs are executed in order, and the last one explicitely sets the value to 'Sales'.
My answer was b, because in the book it says that

...the param and value parameters of the <jsp:setProperty> tag are optional, and should neither attribute be supplied, then the JSP engine assumes that there is a ServletRequest parameter available with the same name as declared by the property attribute.

Since the last setProperty tag was <jsp:setProperty name="usr" property="department" />, and a "department" parameter does exist in the ServletRequest, why isn't the answer Finance(b)??
Thanks,
Marie
Ivan Matmati
Ranch Hand

Joined: Feb 26, 2003
Posts: 41
According to me, you're right.
Have you tried to excute the code?
You know I've already found errors in almost all books I've read!


No Gates!<p>SCPJ 1.4<br />SCWCD 1.4
 
GeeCON Prague 2014
 
subject: bean setProperty