Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP: GetProperty - Scope

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mock Exam Question:
A JSP page has the following useBean declaration that references a bean called Person. The person class has a private field calledfirstname 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"/>
Answer:
a. a
b. b
c. c
d. d
e. e

I answered e, but mock result gives me option a, since in usebean they have mentioned scope as session i think while getting the value we have to put scope attribute.. Correct me if iam wrong
 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getProperty can never contain scope attribute.
 
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic