File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp:getProperty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jsp:getProperty " Watch "jsp:getProperty " New topic
Author

jsp:getProperty

Madhu Sudhana
Ranch Hand

Joined: Apr 16, 2006
Posts: 127
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??


"And the trouble is, if you don't risk anything, you risk even more." -- Erica Jong.
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023

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


There is only one syntax format for jsp:getProperty.
Madhu Sudhana
Ranch Hand

Joined: Apr 16, 2006
Posts: 127
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

Joined: Feb 02, 2006
Posts: 2023
<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

Joined: Apr 16, 2006
Posts: 127
so in the above question choice 2 is also correct option

would you agree with this???
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
Yeap. But if in the real exam, if they only ask for 2 answers, then you'd better not have 2.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:getProperty