Two Laptop Bag
The moose likes Servlets and the fly likes HttpServletResponse.sendError(): need redirect to error page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpServletResponse.sendError(): need redirect to error page" Watch "HttpServletResponse.sendError(): need redirect to error page" New topic
Author

HttpServletResponse.sendError(): need redirect to error page

Davin Austin
Greenhorn

Joined: Mar 10, 2013
Posts: 2
I have the following code in doFilter() method, where I get application scoped bean.



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() and sendError() is not useful here?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63208
    
  69

Why would it be important that the URL of the error page be displayed? It's not. That's not the page that was requested. The behavior you are seeing is correct.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Davin Austin
Greenhorn

Joined: Mar 10, 2013
Posts: 2
Thanks. I just thought that it is better approach to display error page address.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63208
    
  69

Why? That's not the page that was requested. What advantage would there to be to displaying the URL of an error page?
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: HttpServletResponse.sendError(): need redirect to error page
 
It's not a secret anymore!