views:

54

answers:

1

Hello experts,

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.

+1  A: 

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.

BalusC
Thanks for your answer. I think I did not make myself properly understood. I modified the question, I hope it is clearer. I do ALL my logic in the error servlet. The JSP just displays the data. But even if the servlet and JSP are executed, the result of the JSP is not what I see in my browser. Tomcat for some reason ignores it or something. I get default Tomcat error page instead of custom content from my JSP. This is my problem and I don't know what causes it.
user8172373
P.S. I hate scriptlets :D, so my JSP is nice and clean!
user8172373
Right, the question is now more clear. I modified the answer.
BalusC
Wait, I now see some ambiguity: are you attempting to handle the exception yourself and does the forward point to the error page?
BalusC