当前位置: 技术问答>java相关
Java Servlet中跳转到JSP或HTML页面报错。好象是路径问题! 求教!
来源: 互联网 发布时间:2015-06-28
本文导语: Internal Servlet Error: java.lang.NullPointerException at login.doPost(login.java:63) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWr...
Internal Servlet Error:
java.lang.NullPointerException
at login.doPost(login.java:63)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
=========================================================================
我的代码是:
ServletContext rd = this.getServletConfig().getServletContext() ;
rd.getRequestDispatcher("http://localhost:8080/runserv/zhl/alc/alc_art.htm").forward(req,res);
java.lang.NullPointerException
at login.doPost(login.java:63)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
=========================================================================
我的代码是:
ServletContext rd = this.getServletConfig().getServletContext() ;
rd.getRequestDispatcher("http://localhost:8080/runserv/zhl/alc/alc_art.htm").forward(req,res);
|
朋友,你用的webserver是那一个,我用的是webLogic5.1,它的html和jsp放在
weblogicmyserverpublic_html 下(缺省配置)。我在servlet中是这样跳转到JSP或HTML页面的:
String jspName="/example/example.html";
RequestDispatcher rd=getServletContext().getRequestDispatcher(jspName);
rd.forward(req,res);
weblogicmyserverpublic_html 下(缺省配置)。我在servlet中是这样跳转到JSP或HTML页面的:
String jspName="/example/example.html";
RequestDispatcher rd=getServletContext().getRequestDispatcher(jspName);
rd.forward(req,res);