java dispatcher.forward抛出null异常

时间:2013-02-15 03:36:29

标签: java eclipse jsp servlets requestdispatcher

我收到以下错误

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.NullPointerException
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:548)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:471)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    ahp.CompareCriterionSlider.doGet(CompareCriterionSlider.java:35)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause

java.lang.NullPointerException
    org.apache.jsp.CompareCriterionSlider_jsp._jspService(CompareCriterionSlider_jsp.java:91)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    ahp.CompareCriterionSlider.doGet(CompareCriterionSlider.java:35)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

对于该行:dispatcher.forward(request, response);

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        session.setAttribute("criterions", CriterionRecommander.values() );
        RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/CompareCriterionSlider.jsp");
        dispatcher.forward(request, response);
    }

我在CompareCriterionSlider.jsp

中有WebContent/

我试图设置断点来调试它,但是eclipse(版本:Indigo Service Release 2)给了我:Source not found.

enter image description here

谁投票让我关心给出理由?

1 个答案:

答案 0 :(得分:2)

您的JSP中抛出了一个空指针异常,您需要在JSP中找到导致它的确切代码行。
一种方法是简单地打开jsp的编译java文件,即CompareCriterionSlider_jsp.java:91,然后将其映射到JSP中的行。
一旦你这样做,鉴于它是一个空指针,它应该直截了当地计算错误。