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