This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud and have Kyle Brown, Bobby Woolf and Joseph Yodor on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

jsp:useBean doubt

 
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A JSP page has the following useBean declaration that references a bean called Person. The person class has a private field called firstname and an appropriate getter (accessor) method for retrieving the value of that field.

<jsp:useBean id="person" type="com.examulator.Person" class="com.examulator.Person" scope="session" />

Which of the following is the correct syntax for a getProperty tag to retrieve the value of the instance of Person.

a)
<jsp:getProperty name="person" property="firstname"/>

b)
<jsp:getProperty name="person" property="getFirstname"/>

c)
<jsp:getProperty id="person" property="firstname"/>

d)
<jsp:getProperty name="person" property="firstname" class="com.examulator.Person"/>

e)
<jsp:getProperty name="person" property="firstname" scope="session"/>

According to me the answer is 'e' as the getProperty gets it from the scope session but the answer given is 'a',can anybody let me know which one is correct.
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even I guessed e. But how come a?? Which mock exam was this from? What was the explanation given for choosing a?
 
carina caoor
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its from www.examulator.com summary quiz 2....there's no explanation given
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops...jsp:getProperty does not have the scope attribute. But still how can a be correct?
[ November 28, 2007: Message edited by: Jothi Shankar Kumar Sankararaj ]
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you look into the answer choices : c,d,e are not possible since <jsp:getProperty> doesnt have an id, class or scope attribute. That now leaves us with 2 choices a and b. In choice b, the property name is getFirstName which is incorrect. The property names are taken by stripping out the get and set prefix and by making the first letter lowercase. Therefore, the first choice a is correct
reply
    Bookmark Topic Watch Topic
  • New Topic