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

Ajai
Ranch Hand

Joined: May 29, 2002
Posts: 198
Hi All,
I am having 2 doubts.
1. Related to Anand Chawla 's Mock
Q 48 :-
If I am having two properties for a bean
say
int age ;
String name ;
If I am not setting these properties in JSP page but I am trying to get these using getProperty
e.g.
<jsp:getProperty name="name1" property="age">
<jsp:getProperty name="name1" property="name">
I think the result for age and name should be 0 and null
But exam answer specifies it as
null and null

2.
Consider the following line in JSP page ....... assume body-content as EMPTY
<x:foo><%-- any comment --%></x:foo>
Tomcat does not permit it as Empty tag , whereas
I think as per JSP Spec it should be treated as empty tag.
Please refer JSP.2.3.4 Empty Elements of JSP Spec
which states that
"
As examples, the following are all empty tags:
<x:foo></x:foo>
<x:foo />
<x:foo/>
<x:foo><%-- any comment --%></x:foo>
"
Please advice where am I going wrong???
Thanks
Buggi.
Nazmul Huda Sarkar
Ranch Hand

Joined: Feb 01, 2002
Posts: 317
For age it is 0 (at least in my browser), for name it should be null, but in browser nothing is printed... :-(
Anymore help in this issue?


Nazmul<br />SCJP,SCWCD,IBM OOAD with UML
Thambi Rajah
Ranch Hand

Joined: Jul 19, 2002
Posts: 36
**********************************
Q 48 :-
If I am having two properties for a bean
say
int age ;
String name ;
If I am not setting these properties in JSP page but I am trying to get these using getProperty
e.g.
<jsp:getProperty name="name1" property="age">
<jsp:getProperty name="name1" property="name">
***********************************
-----------------------------------
I tried the above JSP code with a JavaBean class. I got the following answer on my browser:
Name
Age 0
-----------------------------------
Thambi
Nazmul Huda Sarkar
Ranch Hand

Joined: Feb 01, 2002
Posts: 317
But in the following jsp code the uninitialized string prints null.
<%! String userName; %>
<%= userName %>
so, in the Bean the uninitialized string should also print null...
Nazmul Huda Sarkar
Ranch Hand

Joined: Feb 01, 2002
Posts: 317
Q.2 Specs says that
<foo><!-- a comment --></foo> is an invalid empty Tag but <x:foo><%-- any comment --%></x:foo> is a valid empty Tag.
Did you miss something on % and !
I didn't check this in Tomcat yet...
[ September 01, 2002: Message edited by: Nazmul Huda Sarkar ]
Raj Paul
Ranch Hand

Joined: Jul 09, 2002
Posts: 77
Hi
Even in orion <just:Tag><%-- empty implementation --%></just:Tag> is not accepted.
Nazmul Huda Sarkar
Ranch Hand

Joined: Feb 01, 2002
Posts: 317
I just test the empty tag issue in Tomcat and does not work when a comment is added... :roll: :roll: :roll:
So..then what about SUN Specs
Maha Annadurai
Ranch Hand

Joined: Oct 27, 2002
Posts: 87
Regarding the question, why null is not printed , the null value is massaged with another method. Here is the code, I have taken out of the generated servlet code for the jsp. I used Tomcat to test this.
out.print(JspRuntimeLibrary.toString((((canopy.AddressBean)pageContext.findAttribute("address")).getStreet())));
I think JspRuntimeLibrary.toString() method takes care of null vaues, and return an empty String instead of null.
Regards,
Maha Anna
[ November 30, 2002: Message edited by: Maha Annadurai ]
 
Consider Paul's rocket mass heater.
 
subject: jsp:getProperty