2 weixin 37188098 weixin_37188098 于 2017.12.28 21:00 提问

javaweb程序一登陆就出错,无法跳转到另一个页面 40C

全是错误报告,不知道哪里出来问题,登陆之后应该跳转到下一个页面的结果也没有跳转,刚学要写课设,级求大神解决

严重: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.jsp.admin_jsp._jspService(admin_jsp.java:156)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at filter.EncodingFilter2.doFilter(EncodingFilter2.java:39)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:716)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
at servlet.Login.doGet(Login.java:36)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at filter.EncodingFilter2.doFilter(EncodingFilter2.java:39)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2527)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2516)
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:745)
org.apache.jasper.JasperException: An exception occurred processing JSP page /admin.jsp at line 35

32: %>
33: <br> 34: function confirmapply(){<br> 35: document.getElementById(&quot;showFrame&quot;).src=&quot;confirm.jsp?dno=&lt;%=worker.getDno()%&gt;&amp;eno=&lt;%=worker.getEno()%&gt;&quot;;<br> 36: }<br> 37: function dnoworker(){<br> 38: document.getElementById(&quot;showFrame&quot;).src=&quot;dnoworkers.jsp?dno=&lt;%=worker.getDno()%&gt;&quot;;</p> <p>Stacktrace:<br> at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:579)<br> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)<br> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)<br> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)<br> at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)<br> at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)<br> at filter.EncodingFilter2.doFilter(EncodingFilter2.java:39)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)<br> at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:716)<br> at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)<br> at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)<br> at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)<br> at servlet.Login.doGet(Login.java:36)<br> at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)<br> at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)<br> at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)<br> at filter.EncodingFilter2.doFilter(EncodingFilter2.java:39)<br> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)<br> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)<br> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)<br> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)<br> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)<br> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)<br> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)<br> at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)<br> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)<br> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)<br> at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)<br> at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)<br> at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2527)<br> at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2516)<br> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)<br> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)<br> at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)<br> at java.lang.Thread.run(Thread.java:745)<br> Caused by: java.lang.NullPointerException<br> at org.apache.jsp.admin_jsp._jspService(admin_jsp.java:156)<br> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)<br> at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)<br> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)<br> ... 42 more</p>

22个回答

qq_35987286
qq_35987286   2017.12.29 09:45

先看下是不是从service跳到admin.jsp的35那里写错了,如果不是,调试跳到程序中看下是不是service哪里写错了。

qq_38377767
qq_38377767   2017.12.28 21:05

java.lang.NullPointerException空指针问题从错误报告自上到下找到你自己写的类就可以找到错误

yanm321
yanm321 问题就是在Login.java的第36号空指针异常了
26 天之前 回复
yanm321
yanm321 空指针问题,你把你得Login.java类贴出来,帮你解决
26 天之前 回复
WY327559435
WY327559435 空指针异常啊
26 天之前 回复
f_fengqingyang
f_fengqingyang 空指针问题自己多研究研究
26 天之前 回复
Kiycherry
Kiycherry 几行几行的写,然后一点一点检查错误或者关掉程序,重新进入。建议不要毫无保留地用复制的代码。
26 天之前 回复
a3060858469
a3060858469 错误报告好乱啊,哪些是有用的错误提示信息??
26 天之前 回复
weixin_37188098
weixin_37188098   2017.12.28 21:10

public class Login extends HttpServlet{
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
String uno=request.getParameter("account");
String pwd=request.getParameter("password");//password
String id=request.getParameter("id");//id
Service w=new Service();
try {
if(w.login(uno,id)!=null)
{
if(w.login(uno,id).getPassword().trim().equals(pwd))
{
System.out.println("登录成功");
if(id.equals("worker")){
request.setAttribute("uno",uno);
ServletContext application=this.getServletContext();
RequestDispatcher rd=application.getRequestDispatcher("/worker.jsp");
rd.forward(request, response);
}
else
{
request.setAttribute("uno",uno);
ServletContext application=this.getServletContext();
RequestDispatcher rd=application.getRequestDispatcher("/admin.jsp");
rd.forward(request, response);
}
}

                loginservlet的代码
a3060858469
a3060858469   2017.12.28 21:22

你看看是不是你要跳转的页面路径写错了??我以前就犯过类似的错误的

u013008179
u013008179   2017.12.28 21:23

at servlet.Login.doGet(Login.java:36) 这行取得值应该是空的 debug模式打断点看下

weixin_41556791
weixin_41556791 卸载后重新安装试试
26 天之前 回复
weixin_37188098
weixin_37188098 好,我试试
26 天之前 回复
weixin_38299517
weixin_38299517   2017.12.28 21:27

可以将你的错误截个图发出来吗?

weixin_37188098
weixin_37188098 我放下面了
26 天之前 回复
IT_YLL
IT_YLL   2017.12.28 21:28

看看你是否有获取request重定向或者转发的时候错误

h19910518
h19910518   2017.12.28 21:33

你看看你的类有没有被实例化

weixin_37188098
weixin_37188098   2017.12.28 21:46

图片说明

pan_ye
pan_ye 可能你重写了init()方法?就是写了init(ServletConfig config)这个?
26 天之前 回复
pan_ye
pan_ye 可能是重写了init()方法?就是写了init(ServletConfig config)这个?
26 天之前 回复
YX5337934887
YX5337934887   2017.12.28 22:47

是你的admin.jsp里报的错, 找到那个编译生成的admin_jsp.java,

看156行有什么问题

YX5337934887
YX5337934887 回复weixin_37188098: 在tomcat下面的work目录底下,一直往下点,找到你的项目名所在的文件夹,在org\apache\jsp这个目录底下有
25 天之前 回复
weixin_37188098
weixin_37188098 没有这个文件啊
26 天之前 回复
共22条数据 1 3 尾页
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!