when i try to redirect my servlet to error page "error.jsp" using response.sendRedirect("/error.jsp") it shows page not found error but when i change it to response.sendRedirect(“error.jsp”), it works fine!
why is it so? why is relative path not working? error.jsp is saved in WEB-CONTENT folder.
The dispatcher.foreward(request,response), works fine with relative url “/page01.jsp”, even though both page01.jsp and error.jsp are in same directory WEB-CONTENT.
please explain.
thanks!
If you pass a String starting with ‘/’ to
HttpServletResponse#sendRedirectthe path will be relative to the server and not your application. So, you should pass something like this to get this working:response.sendRedirect("/myapp/error.jsp");