Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:getProperty

 
Ajai
Ranch Hand
Posts: 198
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Thambi Rajah
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
**********************************
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
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Even in orion <just:Tag><%-- empty implementation --%></just:Tag> is not accepted.
 
Nazmul Huda Sarkar
Ranch Hand
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic