Tomcat ignores my custom error servlet/page
I have an issue which drives me crazy. Not sure it this is a bug in Tomcat or just my plain stupidity but here goes.
I have a custom error servlet set up, something like this. The setup works and if I simulate exceptions or 404 errors etc the servlet 开发者_如何转开发runs, the error page is displayed corectly, the response code is either 500 or 400... well, it works.
But the above setup does not suite me and I need to forward to a JSP (I do my operations in the servlet, put the appropriate data in request scope and forward to the JSP for displaying).
So, in my doPost/doGet method in the servlet I do:
getServletContext().getRequestDispatcher(...).forward(request, response);
The new setup works up to one point. That is, the servlet runs and forwards to the JSP, the JSP executes (I placed log instructions in it and they are executed) but in the browser I get the default tomcat error page, not the content of my JSP.
I also set up <%@page isErrorPage="true"%>
in my JSP but it does not matter if it is present or not, after the JSP is executed its response just vanishes and I get the default Tomcat error page in the browser.
Does anyone now why this does not work? I am going crazzzzzzzyyyyyyyy!
Thank you all!
P.S. I am using Tomcat 5.5.26.
Most likely just an exception has been thrown. Is the custom error page showing exception details? If not, have you checked the server logs in /logs
folder to see if an exception has occurred? What does the error page say if you display ${exception}
(when having isErrorPage="true"
in the error page)? Note that isErrorPage="true"
should not go in "normal" JSP files.
精彩评论