When using the default implementation and an Exception is thrown, a very user un-friendly "Apache Tomcat/4.0.6 - HTTP Status 500 - Internal Server Error" page appears. We don't want the user's to see this!
However, us techies like it because it tells use where to find our errors under the "root cause" label. Just have to scroll down a little.
So, to present a better looking error page I added the following to the web.xml file. <error-page> <exception-type>java.lang.Exception</exception-type> <location>/jsp/messagePage.jsp</location> </error-page>
That works great, but I no longer have anyplace to find the "root cause".
Does anyone know how get a copy of the object that contains contains "root cause" in my messagePage.jsp so I can send it to the console using a scriptlet instead of letting Tomcat send it to the web browser?
Or just some way to get the "root cause" to the console and let the messagePage.jsp do whatever it does.
If messagePage.jsp is declared as an error page, it will have an implicit exception object available.
Better suggestipn: make your error handler a servlet that can do any amount of error processing you want and then forward on to a simple and friendly user-facing page. The error information, including the exception thrown, is available as container-created request attributes.
Another suggestion for you (if this works in your architecture)...
At work i've coded my error pages to be 'friendly' to everyone, and for anyone with an IP address that begins 10.0.0.*, I also output the stacktrace.
All of us at work are inside the firewall, and so we all have IP's that start with 10.0.0.*
This works only while a developer is inside the building, but then, that's where we'd want the stacktrace showing up. Whilst our customers and sales people... if they get a problem, it only shows the 'nice' page.
Joined: Nov 11, 2003
Bear and Mike,
I found an excellent solution. I think it's along the lines of what Bear suggested.