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

JSF : redirect errors to error page

 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

I am trying ( using jsf ) to redirect the errors to the error page errors.jsp , but the following does not work ( part of web.xml)




because when i am trying to access a page which does not exist in my application it display the page with code
HTTP Status 404


is my there anything wrong in my above code , what is the best way to redirect jsf errors to error pages with example if possible.
 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

I have changed the code as the following





error.jsp





by the way the above code redirect to error.jsp if there is error but the contents of error.jsp will not be displayed properly i mean only blank page will be displayed ..........
any one can help me to display the content of error.jsp properly.........................

 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any reply
 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suresh

Try with this example

This is the web.xml



The errorDisplay.xhtml



And the Managed Bean "error"


I hope this example will serve to show the error information that you need.

Regards

Cesar

 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suresh

I forgot to tell you, when you use the this mechanism to show error page you have several objects that contains important information, that objects are placed in the request map.


KeyValueType
javax.servlet.error.status_codeThe HTTP error codeInteger
javax.servlet.error.messageA description of the errorString
javax.servlet.error.exception_typeThe class of the exceptionClass
javax.servlet.error.exceptionThe exception objectThrowable
javax.servlet.error.request_uriThe path to the application resource that encountered the errorString
javax.servlet.error.servlet_nameThe name of the servlet that encountered the errorString


For example if you need to get the page that produce the exception you can do it,


Regards

Cesar
 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cesar for you reply ,

I have implemented your above code but I have got new error


when redirecting to exception.jsf





Any suggestion
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic