views:

13

answers:

2

If my JSF applications, I'll sometimes come across a bug that, for example, corrupts a user session bean somewhere and the user is stuck looking @ a bunch of java exception gobbly-gook on their screen. The only way they can fix this is to restart their browser.

Instead, I would like the application to handle something like this gracefully...basically by being able to catch any of these uncaught exceptions and display an error message (and or possibly contain a link to allow the user to logout/login so they don't have to restart their browser).

Is there a way for JSF to do this easily? If not, does anyone have a solution for this?

+1  A: 

You can just create a custom error page and define its location in <error-page> in web.xml.

E.g.

<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/error.jsp</location>
</error-page>

You've all freedom to make it look like the way you want.

BalusC
Thanks. That's exactly what I was looking for!
wfsaxton
A: 

Aim for the solution proposed by BalusC since in the long term is the easier thing to maintain, otherwise you could try something like this (actually I already did something similar by defining my own custom view handler for exception handling): Custom JSF/Facelet Exception Handling

Abel Morelos