Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:useBean doubt

 
carina caoor
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.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC 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: 10128
3
Eclipse IDE Mac PPC 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 ]
 
Sumi Festus
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic