I have the following code in doFilter() method, where I get application scoped bean.
if (request.getServletContext().getAttribute("resource")==null) {
response.sendError(503);
return;
}
I mapped 503 code to specific error page in web.xml. And I really get content of error page in browser, if error occurs. But the address in address bar doesn't change for error page address: an address of requested servlet leaves there. Is it right behaviour? I'd like to inform explicitly about redirection to error page. Is it only possible with sendRedirect()?
This is the correct behavior. When you use sendError() it will respond to the current request with an error page. If you instead want the URL to change to the error page URL, you will need to use sendRedirect() to respond with a redirect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With