• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom error-page tag drops useful console messages

 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

We're using Tomcat 4.0.6.

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.

Thank You in Advance For Your Help,

Lou
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear and Mike,

I found an excellent solution. I think it's along the lines of what Bear suggested.

http://www.onjava.com/pub/a/onjava/2002/10/30/jakarta.html

Scroll down to Customizing the Exception Handler.

Thanks,

Lou
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a great solution... if you're using Struts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic