我无法使用RequestDispatcher转发来调用JSP

时间:2011-09-10 10:52:29

标签: jsp servlets

我有这个servlet调用这个JSP

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>


<%

 %>
</body>
</html>

但不知道为什么这会给我这个错误

  

2011年9月10日下午4:15:23 org.apache.catalina.core.StandardWrapperValve   调用SEVERE:servlet的Servlet.service()测试抛出异常   java.lang.NullPointerException at   org.apache.jsp.Mine_jsp._jspInit(Mine_jsp.java:22)at   org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)at   org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:164)     在   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:338)     在   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)at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)     在   org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)     在   org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)     在   org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)     在Test.doGet(Test.java:31)at   javax.servlet.http.HttpServlet.service(HttpServlet.java:617)at at   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)at at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)     在   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)     在   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)     在   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)     在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)     在   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)     在   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)     在   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)     在   org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:588)     在   org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:489)     在java.lang.Thread.run(Thread.java:619)

1 个答案:

答案 0 :(得分:2)

  

显示java.lang.NullPointerException   在org.apache.jsp.Mine_jsp._jspInit(Mine_jsp.java:22)

只要webapp的_jspInit()文件夹中包含特定于servletcontainer的库(例如/WEB-INF/libjsp-api.jar等),j2ee.jar上的NPE就是典型的。这是一个重大错误,这些库属于servletcontainer端。清理/WEB-INF/lib文件夹以将其全部删除。如果你把它们放在那里以克服编译错误,你应该以不同的方式解决它。另请参阅How do I import the javax.servlet API in my Eclipse project?