我们小组做了一个项目,用jsp做了一个动态网页,本来运行的好好的,然后突然就报错了我把错误信息贴上来。type Exception reportmessage 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:527)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:359)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause java.lang.NullPointerException
org.apache.jsp.index_jsp._jspInit(index_jsp.java:24)
org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
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.29 logs.
    我们使用Eclipse的J2EE版本开发的,我看到root cause里面最上面是index_jsp.java中_jspInit()方法出错了,然后就去找这个文件(Eclipse放得真隐蔽啊),路径是:Z:\Java\workspace_java_web\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\score\org\apache\jsp
Z:\Java\workspace_java_web是我的工作空间。    然后找到index_jsp.java的第24行,在_jspInit()方法中:
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();这个真是奇怪,这个方法怎么会出错,而且还是空指针,我把完整的index_jsp.java在2楼贴出来吧,求达人解答。

解决方案 »

  1.   

    package org.apache.jsp;import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import java.sql.ResultSet;
    import cn.edu.nju.software.score2011.servlets.model.ConditionChecker;;public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
        implements org.apache.jasper.runtime.JspSourceDependent {  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();  private static java.util.List _jspx_dependants;  private javax.el.ExpressionFactory _el_expressionfactory;
      private org.apache.AnnotationProcessor _jsp_annotationprocessor;  public Object getDependants() {
        return _jspx_dependants;
      }  public void _jspInit() {
        _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
        _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
      }  public void _jspDestroy() {
      }  public void _jspService(HttpServletRequest request, HttpServletResponse response)
            throws java.io.IOException, ServletException {    PageContext pageContext = null;
        HttpSession session = null;
        ServletContext application = null;
        ServletConfig config = null;
        JspWriter out = null;
        Object page = this;
        JspWriter _jspx_out = null;
        PageContext _jspx_page_context = null;
        try {
          response.setContentType("text/html");
          pageContext = _jspxFactory.getPageContext(this, request, response,
           null, true, 8192, true);
          _jspx_page_context = pageContext;
          application = pageContext.getServletContext();
          config = pageContext.getServletConfig();
          session = pageContext.getSession();
          out = pageContext.getOut();
          _jspx_out = out;      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n");
          out.write("\r\n");
          out.write("\r\n");
          out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n");
          out.write("<head>\r\n");
          out.write("<title>Schema Map</title>\r\n");
          out.write("<meta http-equiv=\"Content-Language\" content=\"English\" />\r\n");
          out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\r\n");
          out.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/style_user.css\"\r\n");
          out.write("\tmedia=\"screen\" />\r\n");
          out.write("</head>\r\n");
          out.write("<body onload=\"load()\" ; onunload=\"GUnload()\">\r\n");
          out.write("\r\n");
          out.write("<div id=\"wrap\">\r\n");
          out.write("<div id=\"header\">\r\n");
          out.write("<div id=\"h_help\"><a href=\"administrator.html\" > <u>Administrator</u></a>\r\n");
          out.write("&nbsp;&nbsp;|&nbsp; &nbsp; <a href=\"help.html\" target=\"_blank\"> <u>Help</u></a>\r\n");
          out.write("&nbsp;&nbsp;|&nbsp; &nbsp; <a href=\"about.html\" target=\"_blank\"><u>About\r\n");
          out.write("&nbsp;Us</u></a></div>\r\n");
          out.write("\r\n");
          out.write("<h1><a href=\"#\">Schema Map</a></h1>\r\n");
          out.write("\r\n");
          out.write("<h2>For Big Events</h2>\r\n");
          out.write("\r\n");
          out.write("</div>\r\n");
          out.write("\r\n");
          out.write("<div id=\"menu\">\r\n");
          out.write("<ul>\r\n");
          out.write("</ul>\r\n");
          out.write("</div>\r\n");
          out.write("\r\n");
          out.write("<div id=\"menubottom\"></div>\r\n");
          out.write("\r\n");
          out.write("<div id=\"content\">\r\n");
          out.write("<div class=\"right\">\r\n");
          out.write("\r\n");
          out.write("\r\n");
          out.write("<h2><a href=\"#\">Schematizing Map</a></h2>\r\n");
          out.write("<div id=\"map\" style=\"width: 640px; height: 300px;\"></div>\r\n");
          out.write("\r\n");
          out.write("<h2><a href=\"#\">Schedule</a></h2>\r\n");
          out.write("<div id=\"articles\">\r\n");
          out.write("<table id=\"table_style\">\r\n");
          out.write("\t<tr>\r\n");
          out.write("\t\t<td id=\"td\">Game</td>\r\n");
          out.write("\t\t<td id=\"td\">Date</td>\r\n");
          out.write("\t\t<td id=\"td\">Time</td>\r\n");
          out.write("\t\t<td id=\"td\">Place</td>\r\n");
          out.write("\t\t<td id=\"td\">Team</td>\r\n");
          out.write("\t</tr>\r\n");
          out.write("\t"); ConditionChecker cc = new ConditionChecker(application);
    ResultSet rs = cc.getScheduleInfor();
    if (rs != null) {
    while (rs.next()) {

          out.write("\r\n");
          out.write("\t<tr>\r\n");
          out.write("\t\t<td id=\"td\">");
          out.print(rs.getString(2));
          out.write("</td>\r\n");
          out.write("\t\t<td id=\"td\">");
          out.print(rs.getString(3));
          out.write("</td>\r\n");
          out.write("\t\t<td id=\"td\">");
          out.print(rs.getString(4));
          out.write("</td>\r\n");
          out.write("\t\t<td id=\"td\">");
          out.print(rs.getString(5));
          out.write("</td>\r\n");
          out.write("\t\t<td id=\"td\">");
          out.print(rs.getString(6) + " VS " + rs.getString(7));
          out.write("</td>\r\n");
          out.write("\t</tr>\r\n");
          out.write("\t"); }
    }

          out.write("\r\n");
          out.write("</table>\r\n");
          out.write("\r\n");
          out.write("</div>\r\n");
          out.write("<div class=\"footer\">Designed by Team Kongfu in <a\r\n");
          out.write("\thref=\"http://software.nju.edu.cn/\">Software Institute, Nanjing\r\n");
          out.write("University, China</a>, For <a href=\"http://score-contest.org/2011/\">SCORE\r\n");
          out.write("2011 Contest </a></div>\r\n");
          out.write("</div>\r\n");
          out.write("\r\n");
          out.write("<div class=\"left\">\r\n");
          out.write("\r\n");
          out.write("<h2>Search Schedule</h2>\r\n");
          out.write("\r\n");
          out.write("<form method=\"post\" action=\"ConditionCheck.do\">\r\n");
          out.write("<fieldset><legend>Search Item</legend>\r\n");
          out.write("\r\n");
          out.write("<p>&nbsp;Game <br />\r\n");
          out.write("<br />\r\n");
          out.write("\r\n");
          out.write("<select name=\"name\">\r\n");
          out.write("\t<option value=\"Select an Item\" selected>Select an Item</option>\r\n");
          out.write("\t<option value=\"football\">Football</option>\r\n");
          out.write("\t<option value=\"basketball\">Basketball</option>\r\n");
          out.write("\t<option value=\"volleyball\">Volleyball</option>\r\n");
          out.write("\r\n");
          out.write("</select></p>\r\n");
          out.write("<hr />\r\n");
          out.write("\r\n");
          out.write("<p>&nbsp;Date <br />\r\n");
          out.write("<br />\r\n");
          out.write("\r\n");
          out.write("<select name=\"date\">\r\n");
          out.write("\t<option value=\"Select an Item\" selected>Select an Item</option>\r\n");
          out.write("\t<option value=\"today\">Today</option>\r\n");
          out.write("\t<option value=\"tomorrow\">Tomorrow</option>\r\n");
          out.write("\t<option value=\"other\">Other</option>\r\n");
          out.write("\r\n");
          out.write("</select></p>\r\n");
          out.write("<hr />\r\n");
          out.write("\r\n");
          out.write("<p>&nbsp;Time <br />\r\n");
          out.write("<br />\r\n");
          out.write("\r\n");
          out.write("<select name=\"time\">\r\n");
          out.write("\t<option value=\"Select an Item\" selected>Select an Item</option>\r\n");
          out.write("\t<option value=\"morning\">Morning</option>\r\n");
          out.write("\t<option value=\"afternoon\">Afternoon</option>\r\n");
          out.write("\t<option value=\"evening\">Evening</option>\r\n");
          out.write("\r\n");
          out.write("</select></p>\r\n");
          out.write("<hr />\r\n");
          out.write("\r\n");
          out.write("<p>Team <br />\r\n");
          out.write("<br />\r\n");
          out.write("\r\n");
          out.write("<select name=\"team\">\r\n");
          out.write("\t<option value=\"Select an Item\" selected>Select an Item</option>\r\n");
          out.write("\t<option value=\"UK\">UK</option>\r\n");
          out.write("\t<option value=\"USA\">USA</option>\r\n");
          out.write("\t<option value=\"China\">China</option>\r\n");
          out.write("\r\n");
          out.write("</select></p>\r\n");
          out.write("<hr />\r\n");
          out.write("\r\n");
          out.write("<p>Place <br />\r\n");
          out.write("<br />\r\n");
          out.write("\r\n");
          out.write("<select name=\"place\">\r\n");
          out.write("\t<option value=\"Select an Item\" selected>Select an Item</option>\r\n");
          out.write("\t<option value=\"GYM_A\">GYM_A</option>\r\n");
          out.write("\t<option value=\"GYM_B\">GYM_B</option>\r\n");
          out.write("\t<option value=\"GYM_C\">GYM_C</option>\r\n");
          out.write("\r\n");
          out.write("</select></p>\r\n");
          out.write("<hr />\r\n");
          out.write("\r\n");
          out.write("</fieldset>\r\n");
          out.write("<input type=\"submit\" value=\"Submit\" id=\"submitButton\" />\r\n");
          out.write("</form>\r\n");
          out.write("\r\n");
          out.write("</div>\r\n");
          out.write("\r\n");
          out.write("<div style=\"clear: both;\"></div>\r\n");
          out.write("\r\n");
          out.write("</div>\r\n");
          out.write("\r\n");
          out.write("</div>\r\n");
          out.write("</div>\r\n");
          out.write("</body>\r\n");
          out.write("\r\n");
          out.write("</html>");
        } catch (Throwable t) {
          if (!(t instanceof SkipPageException)){
            out = _jspx_out;
            if (out != null && out.getBufferSize() != 0)
              try { out.clearBuffer(); } catch (java.io.IOException e) {}
            if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
          }
        } finally {
          _jspxFactory.releasePageContext(_jspx_page_context);
        }
      }
    }
      

  2.   

        我又做了一个测试,项目中还写了一个upload.html,用于测试上传文件的,跟它配套的有一个Servlet来接收上传的文件,我确定这个测试很成功,文件内容如下:
    <html>  <form enctype="multipart/form-data" method="POST" action="StoreXls.do">
    <input type="file" name="schedule" />
    <input type="SUBMIT" value="Submit" />
      </form></html>
        然后我把这个文件的名字给改掉,改成upload.jsp,按说应该是没问题的吧,然后从upload.jsp启动的话,会出现一模一样的错误,求解,请详细说明解决问题的方法,谢谢了。
      

  3.   

    可能是servlet哪里配的出错了吧,猜测
      

  4.   


    可是我的upload.html配合Servlet工作的很好啊。为什么改成upload.jsp就崩溃了。有没有哪位达人知道怎么解决?
      

  5.   

    到网上逛了一下,有人说是因为拷贝了一个jsp-api.jar的包到WEB-INF/lib目录下,删除这个文件即可,估计是拷贝的这个文件跟tomcat有冲突,具体有什么冲突,不知道反正我删了之后是成功了囧