Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

bean setProperty  RSS feed

Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)??
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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!
Just the other day, I was thinking ... about this tiny ad:
Download Free Java APIs to Work with Office Files and PDF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!