I have a JSP page with the specified error page. I call the page from the servlet through:
RequestDispatcher rd = ctx.getRequestDispatcher( jspPage ); rd.include( req, res );
How to determine if a jsp page is being forwarded to a page with an error or not? I want to handle exceptions differently, but no exception is thrown. And unfortunately, I cannot change the JSP page or the error page.
Edit:
I think something like this might work after the line include (), any thoughts?
Object errorServletName = req.getAttribute( "javax.servlet.error.servlet_name" ); if ( errorServletName != null ) { there was an error in the JSP... }
source share