*
The moose likes JSF and the fly likes JSF : redirect errors to error page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF : redirect errors to error page" Watch "JSF : redirect errors to error page" New topic
Author

JSF : redirect errors to error page

Suresh Khant
Ranch Hand

Joined: Feb 27, 2010
Posts: 118
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

Joined: Feb 27, 2010
Posts: 118
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

Joined: Feb 27, 2010
Posts: 118
any reply
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

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


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

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

Joined: Feb 27, 2010
Posts: 118
Thanks Cesar for you reply ,

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


when redirecting to exception.jsf





Any suggestion
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF : redirect errors to error page
 
Similar Threads
error page in web.xml
Error Redirection w/Params?
Configurting all errors to single page
strange error-page problem?
response.sendError & error-page