Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem of getProperty

 
dh chau
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the jsp file do not set the Property of the bean, what is the output ?
<jsp:getProperty name="test" property="name" />
<jsp:getProperty name="test" property="age" />
In the javabean, I define name as String and age as int.
I find that the output is "" and 0, but the output of podar mock exam is null and null.
Why??
Thanks a lot !!!
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The mock is at least partly wrong. Primitives can't be null and int defaults to 0 instead, so age would definitely return 0.
The name would be null by default, but the JSP specification could be clearer on what the container should output for a null value. It does state in the javadoc for JspWriter that print((String)null) should output the string "null", so really a container should do just that.
Bottom line is: the mock is wrong on the age, but your JSP container is wrong on the name
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic