I've overridden the OOTB error handler and it works fine for 404 pages.
For 500 error, I've created a Throwable.jsp and inside the calling service class which internally set the response code 500 and include the page
RequestDispatcher dispatcher = request.getRequestDispatcher(path);
dispatcher.include(new GetRequest(request), response);
Even though I'm setting the 500 error, the page returns 200. And, also, whatever be the content of error page, it's including inside loaded page which is like, it shows headers twice. I believe that 'cos of loading page already has header and another one is coming from error page which is included inside loading page.
Could you please check?
sorry but I think that you are not using the standard way to customize the error handler.
As you can see into the docs , you just only need to overlay the errorhandler from default, without using a request dispatcher.
If you want, you can search also for the ACS Common which has inside some develop in order to use a custom error handler.
BTW: in your case I think that the real issue is that you are performing a dispatch so that the page is returned like a success code.
If you don't want to use the default and standard approach (even if I suggest you to use it); I think that you need to use a redirect in order to avoid this issue.
Let us know.
Already checked. In my case, from the JSP, I'm invoking service and inside that, trying to include the response.
For 404, it works fine but for 500, if I go with include then it doesn't change response status or otherwise if I go with forward or sendRedirect then it throws "Response already committed".
If the error that you are facing is "Response already committed" you could try to change the response buffer in order to have the response not committed when you are setting the status.
Try in this way and let me know if it works.
A suggestion: don't change the value of the buffer with an high value because otherwise you can face some performance issues.