You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Travis Stevens <Tr...@noaa.gov> on 2004/09/24 01:22:20 UTC
printing an object whose toString() method returns null
I did something pretty stupid by having an Object.toString() method
return a null.
When I tried to print that object using
org.apache.jasper.runtime.JspWriterImpl.print(Object o) I received a
NullPointerException. This is because the print method uses
String.valueOf(Object o) method to convert the value into the null
object and then calls JspWriterImpl.write(String s). This write method
tries to get the length of this null string and a null pointer is thrown.
Now I know that this is a programming mistake, but it would have been
nicer if a more specific error message was thrown. This can be easily
accomplished by adding a check to the print(Object o) method that checks
the result of String.valueOf().
Unfortunately, the Jsp 2.0 specification does not address this issue.
The print(Object o) is not documented to throw a NullPointerException,
only an IOException.
Any comments?
-Trav
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org