I am facing issue while using redirect in exception handling.
I am catching all the exceptions by overriding onRuntimeException method of WebRequestCycle. I have a error page that decide what needs to be done with the exception. This page is used in onRuntimeException method.
In this page, i am doing logging and other activities and redirecting to a proper page which shows user friendly message. Many time it works properly and shows the message properly. But sometimes it is unable to do redirect to the required page. It directly shows the exception. In the back end it shows that HTTP response has been already commited and unable to redirect.
ERROR [WebResponse] Unable to redirect to: <URL of my error page>, HTTP Resp
onse has already been committed.
ERROR [RequestCycle] unexpected exception when handling another exception: null
I am using following code to redirect to error page.
getRequestCycle().setRequestTarget( new RedirectRequestTarget(<URL of error page>));
I am not sure why this is happening. My main concern is, it works some time and sometime it does not. Any help will be welcome.