6.2.10 EE GA1, 6.2.X EE, 7.0.X EE, Master
Steps used to reproduce:
- Start the portal on Tomcat (Reproduced with JBoss too, but not tested with others.)
- Deploy the attached 'service-pre-exception-test-hook-126.96.36.199.war' which sets a custom service-pre action that simply throws an exception at each request.
- Go to the welcome page using url http://localhost:8080 and you'll see the content of service-pre error page rendered correctly (servlet.service.events.pre.error.page=/common/error.jsp) - see attached screenshot master_error_page.png
- Go to the welcome page using url http://localhost:8080/web/guest/home
Stacktrace is rendered instead of the error page - see attached screenshot master_HTTP_500.png
The error page content should be rendered just as for URL http://localhost:8080
We set javax.servlet.jsp.jspException attribute on the request. This has benefits for us like the exception object becomes accessible from within error pages (we forward to through RequestDispatcher), and drawbacks like HTTP 500 is set on response, app server's error page processing mechanism is triggered and app server is looking for the corresponding error page definition in web.xml. This way the content of our custom "error page" we forwarded to won't be rendered (except some unpredictable scenarios).
According to section 10.9 Error Handling of Servlet 3 spec. error handling depends on the presence of request attributes named like javax.servlet.error.*. Cleaning up those attributes as well as javax.servlet.jsp.jspException avoids the mechanism to step in and allows proper rendering of the custom page we forwarded to.