• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

bean setProperty

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic