aspose file tools*
The moose likes Servlets and the fly likes How can we set error pags for response.sendError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How can we set error pags for response.sendError" Watch "How can we set error pags for response.sendError" New topic
Author

How can we set error pags for response.sendError

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi

How can we set error pages for response.sendError(ServletResponse predefined ones)

For example response.sendError(ServletResponse.Response_Not_Found)


How can i set error-page in web.xml for this ?


Save India From Corruption - Anna Hazare.
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684


Hi,

Use this configuration for Set error page at web.xml




Still more configuration you can give it web.xml



Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thanks , but this is for error codes

For example instead of 404 cant i directly use Response.SC_NO_DATA_FOUND
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684


Hi,

Use just exception type instead of error code.


Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Nishan Patel wrote:
Hi,

Use just exception type instead of error code.




Exception type will be a different thing , that is for completely Exceptions , i want it for HTTP predefined , For example HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You mean an HTTP 500 error? What's wrong with the first configuration Nishan suggested?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Paul Sturrock wrote:You mean an HTTP 500 error? What's wrong with the first configuration Nishan suggested?


Instead of writing 500 directly , can we use "HttpServletResponse.SC_INTERNAL_SERVER_ERROR" inside web.xml ,this is what i wanted to ask in my question.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No. What do you hope to gain by doing this? The code "500" is the standard.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thanks Paul.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can we set error pags for response.sendError
 
Similar Threads
error page for exceptions
Defining error page
How to turn off Websphere Error Reporter ???
setStatus() vs sendError()
Custom error page