• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mapping To Static HTML Not Working For Custom Exceptions

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings,
I am having a bit of a problem with something that I "think" should be relatively straight-forward. I would like to map a custom exception wrapped in a ServletException to a specialized static HTML error page. However, Tomcat 4.1 and 5.0 don't want to seem to reroute my exception to the page.
Here is my web.xml:

As you can see, I have declared an ExceptionServlet that echoes some data to the console and then throws a ServletException wrapping a DumbException on doGet. The code for the ExceptionServlet is as follows:

The custom exception, DumbException, is as follows:

In my Tomcat webapps directory, TestModule/WEB-INF/classes/test contain my classes, and the output from the ExceptionServlet shows up in the console, but the browser does not display the static web pages, which exist in TestModule/error_pages.
I'm a little baffled? Any ideas on what I'm doing wrong?
TIA,
Jason
[ April 27, 2004: Message edited by: Jason Mowat ]
[ April 27, 2004: Message edited by: Jason Mowat ]
 
Jason Mowat
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings,
Lying in bed, trying to go to sleep, I had a brainstorm about my issue. I was thinking perhaps there was something I had to set in web.xml in conf. That didn't work.
I searched around a bit and found others were having similar problems. Some suggested using jsp instead of html. That didn't work either.
What DID work was turning off "friendly error messages" in IE6. The pages show up fine.
Now my question is: how can you override IE6 without turning that option off but so that it shows the pages you want it to in case of errors? It is conceivable that I would show some exception detail in my web page; IE6 by default hijacks that functionality?
My thoughts are that you have to create an exception handling servlet and forward requests to the html pages without setting the error status codes (which I suspect is what Tomcat is doing and IE is "trying" to be smart and helpful - which it isn't).
Any thoughts or comments?
Cheers,
Jason
 
Jason Mowat
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hehe,
Here is some more info:


> I recall there was an issue with some version of IE: it had
> a "feature ": if the error page is less then x bytes then IE showes
> its ugly default error page. But if the error page is large
> enough (in terms of bytes) then it showes that.
(Anton Tagunov)
You are right! IE shows its default error page if the messages has 341 chars or less. From 342 chars up, it shows the received data...


I haven't asserted that this is true from an IE6 perspective, but it certainly "feels" right. The complete thread can be viewed here.
Cheers,
Jason
 
Jason Mowat
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings,
If the error page doesn't contain enough data, even though it might be a properly formed HTML page, IE defaults to it's own error pages when "friendly errors" are on.
If there is a significant amount of data on the error pages, IE shows it properly.
This is clearly an IE issue and not a Tomcat or configuration issue.
Hope this helps anyone else in need :-)
Cheers,
Jason
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It did help, thanks! Seems like IE has allways some surprise waiting for us.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic