Those pages under WEB-INF are accessible using forward method of RequestDispatcher
. Whats wrong with sendRedirect
?
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.