I am trying to include a jsp page from a servlet:
RequestDispatcher rd = ctx.getRequestDispatcher( jspPage ); rd.include( req, wrapper );
But I get the following exception:
java.lang.IllegalStateException: Cannot forward after response has been committed
The problem is with the JSP page, which points to its own default error page through the JSP error tag. The JSP error page may also throw an exception that leaks to the application-level error page specified in web.xml. Therefore, when the jsp page that I am trying to include throws an exception and the error page also throws an exception, the inclusion fails.
I need to handle this case gracefully, because I turn on user-written modules on the page, and the wrong module should display an exception for the user, and not bomb using IllegalStateException. Any ideas?
source share