Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

jsp:useBean doubt

 
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • 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: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Its from www.examulator.com summary quiz 2....there's no explanation given
 
Joe Harry
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
The longest recorded flight time of a chicken is 13 seconds. But that was done without this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic