permaculture playing cards
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

bean setProperty

Marie Mazerolle
Ranch Hand

Joined: Oct 01, 2002
Posts: 81
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:"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)??
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
I agree. Here's the link:
subject: bean setProperty
It's not a secret anymore!