aspose file tools*
The moose likes Servlets and the fly likes web.xml error-page not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

web.xml error-page not working

Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
Hi,
I am using Tomcat 5.5.25 and cannot get my error page to work. Do I have to enable something in Tomcat to tell it to use my error-page definitions in web.xml? I have spent way too much time on such an easy thing. Thanks

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This is not really a Struts problem. I'm moving it to the Servlets forum to increase the likelihood you'll get an aswer.


Merrill
Consultant, Sima Solutions
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

When you say, "it's not working" what exactly do you mean?

Are you seeing the Tomcat default 404 page (will show 'Apache Tomcat' along with the version number.

Or.. Are you seeing a more generic looking 'page not found' screen?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
Hi, sorry Ben. I get a Page Not Found.

I also tried adding:


But I also get a Page Not Found.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

This still doesn't answer my question.

What does the page not found screen look like?
Is it an Apache Tomcat page not found screen or is it more generic looking?
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225




It has no apache.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

OK, it sounds like you might be looking at MSIE's 'Friendly Error Screen'

Go to Tools -> Options -> Advanced (tab) and uncheck the "Show Friendly Errors" checkbox.
Then try again.
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
Wow that was it. Thanks!

Any other advice around this setting, as far as how to code for this? Or is that just the way it will have to work for users with that setting?
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
If the Show Friendly URLs setting is set to true as defaulr in IE, then this web.xml error-page is going to be kindof not worthwhile isnt it?

Most of my users use IE and wouldnt even know how to modify this setting. Please let me know your thoughts.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Andy Hahn:

Most of my users use IE ....


There's your problem.



Seriously though.
MSIE sees the 404 status code and shows this page.
I've never tried this but try setting the status to 200 in your error jsp.

<% response.setStatus(200); %>
This should tell the browser that the request was valid and it will show your page instead of the 'Friendly Error Page'.
[ March 13, 2008: Message edited by: Ben Souther ]
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
Yeah that does work. Sweeeeet thanks!
kamalakannan kamal
Ranch Hand

Joined: May 19, 2008
Posts: 32
Hi,

but error-page is working fine with tomcat 4.1 without changing any settings in IE? what may be the reason for this?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

kamalakannan kamal,

Rather than tacking your new question onto someone else's old thread, create a new thread for yourself. It will stand a better chance of getting answered and nobody will accuse you of hijacking someone else's discussion.

You can refer to this thread with a link if you think the discussion here is relevant to your question.

-Ben
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: web.xml error-page not working