Consider the hierarchy :
I moved my JSPs from WEB-INF
to the src
folder .However when I try to dispatcher.forward()
, I get :
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
controller.LoginPage.doPost(LoginPage.java:214)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.50 logs.
Apache Tomcat/7.0.50
The specified exception occurs in the lines :
String addressPath = "/../view/admin/adminPage.jsp";
RequestDispatcher dispatcher = request.getRequestDispatcher(addressPath);
dispatcher.forward(request, response);
How can I fix the path ?
Thanks
The fact that your JSP is in a source folder seems to indicate that it will be placed in
/WEB-INF/classes/view/admin/
Which is really not where
String addressPath = "/../view/admin/adminPage.jsp";
is pointing it to.
getRequestDispatcher
returns null
if the Servlet container cannot return a RequestDispatcher
for the given path.
JSPs shouldn't really be under /WEB-INF/classes
. Put them in a dedicated folder like /WEB-INF/jsp/view
and access them there.
You could then access it with
String addressPath = "/WEB-INF/jsp/view/admin/adminPage.jsp";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.