• 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

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers
This is one of the question which I have faced in a mock exam


Question :

Which of the following are valid declarations in a JSP page? [Check all correct answers]

1. <jsp:getProperty Name="id" Property="streetName"/>
2. <jsp:getProperty property="streetName" name="id"></jsp:getProperty>
3. <jsp:getProperty name="id" class="com.baboon.scwcd.Address" property="streetName"/>
4. <jsp:getProperty name="id" property="streetName"/>
5. <jsp:getProperty property="streetName" name="id"/>

Explaination:

You have answered: 2 4 5 - This is incorrect
Answer 4 and 5 are correct.
The JSP tag getProperty has 2 mandatory attributes. The attribute "name" refers to the Java bean instance from which the required property will be obtained.
The attribute "property" is the name of the property, it is the value stored in this property that will be retrieved.
Answer 3 is incorrect, the attribute class is invalid for the getProperty tag.
Your Java bean must comply to the Java Beans specifications, the property to be retrieved must have the appropriate getters and setters implemented in the Java Bean.

I expect the choice 2 is also correct

help me if I am wrong??
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


JSP Syntax
<jsp:getProperty name="beanInstanceName" property="propertyName" />



There is only one syntax format for jsp:getProperty.
 
Madhu Sudhana
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply


and I didn't get the difference between

<jsp:getProperty name="beanInstanceName" property="propertyName" />

and

<jsp:getProperty name="beanInstanceName" property="propertyName" ></jsp:getProperty>

as both contain no body

could you explain this
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<jsp:getProperty name="beanInstanceName" property="propertyName" ></jsp:getProperty> implies that the syntax getProperty can have body.

There is nothing wrong to use it.
 
Madhu Sudhana
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so in the above question choice 2 is also correct option

would you agree with this???
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeap. But if in the real exam, if they only ask for 2 answers, then you'd better not have 2.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic