This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Problems with redirect after catching Exception (JSF 2) 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 "Problems with redirect after catching Exception (JSF 2)" Watch "Problems with redirect after catching Exception (JSF 2)" New topic
Author

Problems with redirect after catching Exception (JSF 2)

Melanie Kirchner
Greenhorn

Joined: Dec 04, 2008
Posts: 2
Hi all,

I have a problem with the redirect in my custom ExceptionHandler. The ExceptionHandler should handle NullPointerExceptions and perform a redirect if an exception occures. Here is the part of the Handler that is responsible for the redirect:



I have a simple page to test the ExceptionHandler:



And in the getter-Method for firstname I force a NullPointerException:



The redirect to my error page works fine for this little example but when I add considerable more content on the page (like a menu with many entries and icons) the redirect doesn't work because the response is already commited in the exceptionHandler method. I also tried to redirect to the error page via response.sendRedirect() but the same problems occured.

Why is the response already commited? Is there any context-param or anything else to prevent this behavior?

Thanks
 
Don't get me started about those stupid light bulbs.
 
subject: Problems with redirect after catching Exception (JSF 2)
 
Similar Threads
How to handle exception in JSF2.0?
illegalstateexception i am getting
Exception Handling...For Marty Hall..and All
java.lang.IllegalStateException: Cannot create a session after the response has been committed
java.lang.illegalstate exception