tags:

views:

39

answers:

1

Stacktrace:

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

java.lang.NullPointerException
    org.apache.jsp.jsp.Report_jsp._jspService(Report_jsp.java:79)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
+1  A: 

To the point: just read the stacktrace and fix the null pointer accordingly.

The first line of the stacktrace should contain a line number of the source code where it is been caused. Open the compiled source code of Report.jsp and go to that line. It should look like:

someObject.doSomething();

Especially look there where the dot operator . is used to access or invoke some object instance. A NullPointerException on such a code line means that the someObject is actually null. It simply refers nothing. You can't access it nor invoke any methods on it.

All you need to do to fix a NullPointerException is to ensure that someObject is not null:

if (someObject == null) {
    someObject = new SomeObject();
}
someObject.doSomething();

Or alternatively only do the access/invocation if someObject is not null.

if (someObject != null) {
    someObject.doSomething();
}

That said, as taglibs and EL are usually NPE-safe, this indicates that you wrote raw Java code inside JSP files using the old fashioned scriptlets. I would strongly recommend not to do so, but just to write Java code in real Java classes and use taglibs to control the page flow and output and use EL to access backend data.

BalusC