The pages under WEB-INF
are not accessible from outside the web application.
Now, since using HttpServletResponse#sendRedirect()
, a new request is created by client, so the request is actually sent from the browser, and therefore you cannot have WEB-INF
in path to sendRedirect
.
In case of RequestDispatcher
, the methods - forward()
and include()
, doesn't ask the client to create a new request, rather they use the same request to forward to/include a different page from most probably the Servlet Controller. That is why you can give path to a file under WEB-INF
, as you are accessing it from inside the web application only.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…