JSF2 exception handling

What is the best way to handle "unchecked" exceptions in a JSF2 web application?

I am currently letting them go to the servlet container, and I am redirecting (via the web.xml file) to the jsp error page showing a friendly message and exception information.

Is it better to handle them with a "custom exception handler" (for example, Ed Burns says in the book "JSF 2.0 - full link").

In both cases ("web.xml" or "exception handler"): Do I need to redirect to the jsp page instead of the facelet page? (because the exception may be caused by the jsf problem itself and may lead to a loop). Or can I redirect to the facelet page? Redirecting to a jsp page has the disadvantage that you need to configure the jsf application to access both jsp and facelets (it will be more "clean" with only front pages).

Finally, another question: Does the "Special Exception Handler" also handle "checked" exceptions? I am currently processing them in managed beans (catch them and show facemessage on the application page).

+5
source share
1 answer

What is the best way to handle "unchecked" exceptions in a JSF2 web application?

It all depends on the functional requirements. Excluded exceptions usually indicate errors and configuration problems in your web application. They usually cannot be caught, but simply injected into a container. This is usually not an end-user error, but only a developer or serveradmin error.


I am currently letting them go to the servlet container, and I am redirecting (via the web.xml file) to the jsp error page showing a friendly message and exception information.

Is it better to handle them with a "custom exception handler" (for example, Ed Burns says in the book "JSF 2.0 - full link").

, (ajax, XMLHttp) , <error-page> web.xml. , , JavaScript. ( HTTP-) <error-page> web.xml.


( "web.xml" " " ): jsp facelet? ( jsf ). facelet? jsp , , jsf jsp, facelets ( "", ).

, . , JSP Facelets. JSP .


, : " " "" ? beans ( facemessage ).

.

+6

All Articles