• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Problem with Custom Error Page

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a problem with a custom error page. I have the following information in my web.xml file:



Here is FileNotFound.java



And then my JSP



And all I get is the default HTTP 404 File Not Found page. I don't get my custom page. I don't even get Tomcat's default error page unless I remove the custom error from the web.xml file.

I have also tried specifying the JSP instead of mapping through a servlet but that gets me the same bad results. Any tips?

Thanks.
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about adding a printout to your processRequest to check if you get there?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it is getting to the servlet. If I explicity call that error page using my servlet mapping

http://localhost:8080/anykey/filenotfound

I see the error page just fine. But if I call some arbitrary page that doesn't exist, I get the default HTTP 404 Page Not Found that most HTTP Servers tend to throw. Not even the Tomcat specific 404.
[ July 30, 2004: Message edited by: Gregg Bolinger ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just did a test here at home with a fresh test project that only has an index page and an error page and everything works fine. So I guess I am going to have to see what is different when I get back to work.

This is so strange though because I did everything exactly the same...
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had the same problem yesterday with my web.xml definition
<error-page>
<error-code>404</error-code>
<location>/common/jsp/errorPage.jsp?ID=404</location>
</error-page>
I always received the default 404-page of the browser.

Solution:
there is a minimum limit of the errorpage size.
Add some more text to your errorpage and it'll work (hope so)

have a look at:
http://www.404-error-page.com/404-error-page-too-short-problem-microsoft-ie.shtml
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(After only a quick read...)

Are you testing with IE? Only IE? Is IE configured to display "friendly" error pages?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bruno Marti:
I had the same problem yesterday with my web.xml definition
<error-page>
<error-code>404</error-code>
<location>/common/jsp/errorPage.jsp?ID=404</location>
</error-page>
I always received the default 404-page of the browser.

Solution:
there is a minimum limit of the errorpage size.
Add some more text to your errorpage and it'll work (hope so)

have a look at:
http://www.404-error-page.com/404-error-page-too-short-problem-microsoft-ie.shtml



That is the most retarted thing I have ever witnessed. But all is well now that I made my error page longer. :roll:

Thanks a bunch.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So here is something else interesting that is happening. Now, not matter what page I visit in my web app, my FileNotFound class is being ran. The app functions as normal, except I have a System.out.print in the FileNotFound servlet and it is printing my out statement about 3 times per page. Is this normal?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, after some better debugging...I have some images that I have not fixed the url on to display and appearntly for ANY resource that the server can't find you get a 404. So it was calling my error page for those images not being available. I didn't realize it did this.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I spent a day and a half trying to figure out what the heck was going on until I stumbled on your solution.

That's quite possibly the single stupidest policy on error pages I can think of.

Thanks a bunch for the clue-in!
 
reply
    Bookmark Topic Watch Topic
  • New Topic