You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Robert Baruch <au...@zoominternet.net> on 2005/10/24 16:13:21 UTC

Problem getting custom 404 error working on 4.1.31

Hi all,

I've been scratching my head over this for a few days, and I just  
can't see what I'm doing wrong. I am running 4.1.31 under JDK 1.4.2.

Basically, I've taken the default install of 4.1.31 on Windows. The  
only difference from default is that I've installed in D:/Tomcat 4.1.31

In the conf/web.xml file, I have added this after the welcome-file- 
list block:

<error-page>
   <error-code>404</error-code>
   <location>/file_not_found.html</location>
</error-page>

I have also put file_not_found.html into webbaps/ROOT. It just looks  
like this:

<html>
<body>
There was a problem with your request, please try again
</body>
</html>

Those are the only changes I have made to the default 4.1.31  
installation.


The problem appears to be that the file_not_found.html page is  
returned, but with an HTTP 404 status code. I'd like an HTTP 200  
status code (OK) to be returned.

The issue is that when I pull up firefox and try to go to a page that  
doesn't exist, such as http://127.0.0.1:8080/nonono, I do get my  
page. But when I pull up IE, the browser is showing its default 404  
"The page cannot be found" page. I'd just like to see my error text.

Any ideas on how to do this?

Thanks,

--Rob


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Problem getting custom 404 error working on 4.1.31

Posted by Hassan Schroeder <ha...@webtuitive.com>.
Robert Baruch wrote:

> Basically, I've taken the default install of 4.1.31 on Windows. The 
> only difference from default is that I've installed in D:/Tomcat 4.1.31

Not related to your question, but spaces in path names involving
Tomcat are a Bad Idea; check the archives for confirmation :-)

> The problem appears to be that the file_not_found.html page is 
> returned, but with an HTTP 404 status code. I'd like an HTTP 200  status
> code (OK) to be returned.

Again, not related, but this is also a Bad Idea; it subverts the
reasons for having meaningful headers, and will prevent your using
an automated link checker on your app -- which will cheerfully tell
you that "everything's fine! got all response code 200s from all of
your site links; no problems". Yeah. Have a nice day :-)

> The issue is that when I pull up firefox and try to go to a page that 
> doesn't exist, such as http://127.0.0.1:8080/nonono, I do get my  page.
> But when I pull up IE, the browser is showing its default 404  "The page
> cannot be found" page. I'd just like to see my error text.
> 
> Any ideas on how to do this?

1) uncheck the default IE setting (Internet Options -> Advanced ->
   'Show friendly HTTP error messages') that controls this.
2) make your 404 error message large enough to convince IE it's a
   real page. :-)

   google[ "Internet Explorer" "custom 404" size ] ->

<http://www.404-error-page.com/404-error-page-too-short-problem-microsoft-ie.shtml>


HTH,
-- 
Hassan Schroeder ----------------------------- hassan@webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                          dream.  code.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Problem getting custom 404 error working on 4.1.31

Posted by "Seak, Teng-Fong" <se...@yahoo.com>.
    I'm using IE 6 SP1 but I found that I have to stuff the page up to
more than 1024 bytes to make the so-called "friendly" error page disappear.

    OTOH, I've found a pitfall with IE.  It's not enough to click the
"refresh" button to test this.  I have to quit it and reopen it again
after every change to my customized error page to make it take effect. 
A real pain in the ass!

Robert Graf-Waczenski wrote:

>IE can be a PITA when it comes to error page display... ;-))
>
>Check if your IE is configured with "friendly HTTP error messages". If
>this setting is enabled, IE displays its own "friendly" version of an
>error page and simply skips the server response. To avoid this
>nonsense-like behavior, your error page must be "sufficiently big", i.e.
>the response must be more than a few chars of HTML code, as seems to be
>the case with your page.
>For the fun of it: Try adding HTML comments to your error page and see
>what happens if the amount of them exceeds a threshold value (around 500
>bytes total response size IIRC). Comments are fine for this, it is
>important that the server response size is big enough.
>
>Robert
>
>  
>
>>-----Original Message-----
>>From: Robert Baruch [mailto:autophile@zoominternet.net]
>>Sent: Monday, October 24, 2005 4:13 PM
>>To: users@tomcat.apache.org
>>Subject: Problem getting custom 404 error working on 4.1.31
>>
>>
>>Hi all,
>>
>>I've been scratching my head over this for a few days, and I just
>>can't see what I'm doing wrong. I am running 4.1.31 under JDK 1.4.2.
>>
>>Basically, I've taken the default install of 4.1.31 on Windows. The
>>only difference from default is that I've installed in
>>D:/Tomcat 4.1.31
>>
>>In the conf/web.xml file, I have added this after the welcome-file-
>>list block:
>>
>><error-page>
>>   <error-code>404</error-code>
>>   <location>/file_not_found.html</location>
>></error-page>
>>
>>I have also put file_not_found.html into webbaps/ROOT. It just looks
>>like this:
>>
>><html>
>><body>
>>There was a problem with your request, please try again
>></body>
>></html>
>>
>>Those are the only changes I have made to the default 4.1.31
>>installation.
>>
>>
>>The problem appears to be that the file_not_found.html page is
>>returned, but with an HTTP 404 status code. I'd like an HTTP 200
>>status code (OK) to be returned.
>>
>>The issue is that when I pull up firefox and try to go to a
>>page that
>>doesn't exist, such as http://127.0.0.1:8080/nonono, I do get my
>>page. But when I pull up IE, the browser is showing its default 404
>>"The page cannot be found" page. I'd just like to see my error text.
>>
>>Any ideas on how to do this?
>>
>>Thanks,
>>
>>--Rob
>>    
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Problem getting custom 404 error working on 4.1.31

Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
IE can be a PITA when it comes to error page display... ;-))

Check if your IE is configured with "friendly HTTP error messages". If
this setting is enabled, IE displays its own "friendly" version of an
error page and simply skips the server response. To avoid this
nonsense-like behavior, your error page must be "sufficiently big", i.e.
the response must be more than a few chars of HTML code, as seems to be
the case with your page.
For the fun of it: Try adding HTML comments to your error page and see
what happens if the amount of them exceeds a threshold value (around 500
bytes total response size IIRC). Comments are fine for this, it is
important that the server response size is big enough.

Robert

> -----Original Message-----
> From: Robert Baruch [mailto:autophile@zoominternet.net]
> Sent: Monday, October 24, 2005 4:13 PM
> To: users@tomcat.apache.org
> Subject: Problem getting custom 404 error working on 4.1.31
>
>
> Hi all,
>
> I've been scratching my head over this for a few days, and I just
> can't see what I'm doing wrong. I am running 4.1.31 under JDK 1.4.2.
>
> Basically, I've taken the default install of 4.1.31 on Windows. The
> only difference from default is that I've installed in
> D:/Tomcat 4.1.31
>
> In the conf/web.xml file, I have added this after the welcome-file-
> list block:
>
> <error-page>
>    <error-code>404</error-code>
>    <location>/file_not_found.html</location>
> </error-page>
>
> I have also put file_not_found.html into webbaps/ROOT. It just looks
> like this:
>
> <html>
> <body>
> There was a problem with your request, please try again
> </body>
> </html>
>
> Those are the only changes I have made to the default 4.1.31
> installation.
>
>
> The problem appears to be that the file_not_found.html page is
> returned, but with an HTTP 404 status code. I'd like an HTTP 200
> status code (OK) to be returned.
>
> The issue is that when I pull up firefox and try to go to a
> page that
> doesn't exist, such as http://127.0.0.1:8080/nonono, I do get my
> page. But when I pull up IE, the browser is showing its default 404
> "The page cannot be found" page. I'd just like to see my error text.
>
> Any ideas on how to do this?
>
> Thanks,
>
> --Rob
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org