Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can we set error pags for response.sendError

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

Use this configuration for Set error page at web.xml




Still more configuration you can give it web.xml


 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

Use just exception type instead of error code.


 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean an HTTP 500 error? What's wrong with the first configuration Nishan suggested?
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. What do you hope to gain by doing this? The code "500" is the standard.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic