• 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.
 
Sandeep Krish
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jsp:getProperty does not have an attribute scope. Only useBean has scope.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic