我有一个代码,其中包括使用会话从Servlet到Jsp的后端查询的结果。有10个jsp页面需要与各个servlet相同的功能。我最初的2页完全可以正常工作,但是即使使用相同的代码,后面的页面也很难。
即将出现的错误是: org.apache.catalina.core.ApplicationDispatcher调用警告:Servlet Gemserver当前不可用
其中Gemserver是我的Servlet,gem.jsp是jsp。
由于显示为Unavailable,因此给我以下错误:jsp中的java.lang.NullPointerException
这是针对Tomcat 9.0和Eclipse的。
gem.jsp:
用于导入servlet的内容
web.xml:
<!-- GEM -->
<servlet>
<br><description></description><br/>
<servlet-name>Gemserver</servlet-name>
<servlet-class>project.Gemserver</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Gemserver</servlet-name>
<url-pattern>/Gemserver</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<servlet-name>gem_yr</servlet-name>
<servlet-class>project.gem_yr</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>gem_yr</servlet-name>
<url-pattern>/gem_yr</url-pattern>
</servlet-mapping>
完整错误:
Jun 25, 2019 7:47:44 AM org.apache.catalina.core.ApplicationDispatcher invoke
WARNING: Servlet [Gemserver] is currently unavailable
Jun 25, 2019 7:47:44 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/NIC_data] threw exception [An exception occurred processing JSP page [/gem.jsp] at line [306]
303: <div class="animated flipInY col-lg-2 col-md-2 col-xs-12">
304: <div class="tile-stats">
305:
306: <div class="count" align="center"><%=status1_total.get(0) %></div>
307:
308: <h2><center>FILLED</center></h2>
309:
Stacktrace:] with root cause
java.lang.NullPointerException
at org.apache.jsp.gem_jsp._jspService(gem_jsp.java:435)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1366)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)