Problem Statement : If any of the component in a page throws 500 error(HTTP Status code), whole page gets broken.
Solutions Tried : We created a JSP (Exception.jsp) in the path /apps/sling/servlet/errorhandler/. In Exception.jsp, we have written single line of code which is :
Actual Outcome : If we try to hit the promblematic component manually(http://<page><component>.html), then status code comes as 500, but in case if we hit the page (http://<page>.html), then page comes totally broken and status code is coming as 200 for the page.I've checked one more thing which is "response.isCommitted()". This comes as "false" when we hit the component, but gives "true" when we hit the page, which signifies that status code can't be altered for the page.
We are looking for a solution in which :
1. Either the problematic component(component which is throwing 500 error) does not show at all on the page and rest of the page works fine.
2. Page may be broken, but status code for whole page should be 500.
Any help would be highly appreciated.
You can configure your application to use custom error handling machenism. by default it uses /libs/sling/servlet/errorhandler to handle all the exception, to customize it you have to create same structure under /apps folder like /apps/sling/servlet/errorhandler. To handle 500 exception you have to create Throwable.jsp and handle it accordingly.
For more information plz refer http://dev.day.com/docs/en/cq/current/developing/customizing_error_handler_pages.html
Let me know if you need more information.