[prev in list] [next in list] [prev in thread] [next in thread]
List: japple-user
Subject: Re: [japple-user] How to debug errors in jsp template files?
From: Mark Deneen <mdeneen () japple ! org>
Date: 2002-02-25 19:56:06
[Download RAW message or body]
On Mon, 25 Feb 2002, Michael Schulz wrote:
> How am I to debug this?
>
>
> Saucon Server Exception
> An exception has occurred ...
>
> Message: java.lang.NullPointerException - null
> Class: japple.web.content.IncludedFileService
> Method: include
> Included URL: productListHandler.jsp
>
>
> java.lang.NullPointerException at
> org.apache.jsp.productListHandler$jsp._jspService(productListHandler$jsp.jav
> a:70) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
You are referencing a null pointer in your productListHandler.jsp.
Sometimes the stack trace of a jsp execution is not very clear. I would
take a look at productListHandler$jsp.java (in the
tomcat/work directory), line 70. This should give you a little more
context, and you should be able to see what you referenced when it blew
up.
Be careful of statements such as:
String str = data.get("ac.nothing").toString();
If data.get("ac.nothing") returns null, then the call to toString() will
obviously fail. To make this safer, use a call like this:
String str = data.get("ac.nothing", "default value").toString();
or, if you know it is a String object in client state:
String str = (String) data.get("ac.nothing");
and then
if( str != null ) {
/* code follows */
/* ... */
}
Personally, I prefer the first method. It involves somewhat more overhead
of creating a new String object, it eliminates the null check later on,
and makes the code a bit more compact.
-M
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic