• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bean Problem

 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers ,
When i am using jsp's <jsp:getProperty> tag i am getting a value of null for a bean named errorBean when i am using tomcat5 version while using tomcat 4 version does't return null.My errorBean has just a property named error which is set when a user types in a wrong password or username.ialso am also using <jsp:useBean> tag at the top of my jsp.My question is why is it happening? and what should i do to make it work on tomcat 5.0 version?
Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The spec uses to be unclear about what getProperty should return if the bean's value is null. At the time, Tomcat took what I think was the more useful interpretation and returned an empty string. When the spec was made more clear (getProperty should return what String.valueOf(xxx) should return), Tomcat was changed to comply with the spec.

There was some discussion about making it possible to configure Tomcat to be backward compatible for existing apps but the idea was reject (Tomcat is the reference implementation for the servlet and JSP specs so this makes sense).

I had to go through all of my beans and change the getters to return an empty string if their values were null.

These days, I use EL which will print an empty string for null values.
With EL and JSTL, there is no need to use getProperty anymore.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!