You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Eric B." <eb...@hotmail.com> on 2008/02/06 22:38:02 UTC

Custom 404 for non-existant contexts?

Is there a way to create a custom 404 error page for Tomcat for non-existant 
context paths?

I know how to create a custom 404 error page within my application, but am 
running into an issue while I am redeploying my application.  The users are 
able to access Tomcat, but since my application/context isn't yet deployed 
they are getting Tomcat's standard 404 error page and freak out.

Is there anything I can do to customize it and make it a little more user 
friendly?

Thanks,

Eric




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


Re: Custom 404 for non-existant contexts?

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
you;d have to custom do it

http://people.apache.org/~fhanik/covalent-error-report-valve.jar

Filip

Eric B. wrote:
> Is there a way to create a custom 404 error page for Tomcat for non-existant 
> context paths?
>
> I know how to create a custom 404 error page within my application, but am 
> running into an issue while I am redeploying my application.  The users are 
> able to access Tomcat, but since my application/context isn't yet deployed 
> they are getting Tomcat's standard 404 error page and freak out.
>
> Is there anything I can do to customize it and make it a little more user 
> friendly?
>
> Thanks,
>
> Eric
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>   


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


RE: Custom 404 for non-existant contexts?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: news [mailto:news@ger.gmane.org] On Behalf Of Eric B.
> Subject: Re: Custom 404 for non-existant contexts?
> 
> Would just modifying the ROOT/WEB-INF/web.xml work?

It should, since any unmatched context paths are given to the default
app for processing (and usually a 404).  This is different than creating
a customized error page for a context that fails to deploy properly,
which is what Filip's valve takes care of in addition to the
non-existant context.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


Re: Custom 404 for non-existant contexts?

Posted by "Eric B." <eb...@hotmail.com>.
> |>>
> |>> Is there a way to create a custom 404 error page for Tomcat
> |>> for non-existant context paths?
> |
> |> What happens if you declare a custom error page for the ROOT (default)
> |> webapp?
> |
> | Yeah - that's pretty much the only thing I managed to figure out.  I
> updated
> | the conf/web.xml file to include
> |    <error-page>
> |       <error-code>503</error-code>
> |       <location>/error/maintenance.html</location>
> |     </error-page>
>
> Note that you have modified the default web.xml for all webapps, and not
> the ROOT webapp. This may have unintended consequences for other web
> applications.
>
> | and put the /error/maintenance.html in the ROOT directory.
>
> If you have a ROOT directory, why not use ROOT/WEB-INF/web.xml instead
> of hacking the site-wide defaults?


Hmmm - good question.  Don't know why I didn't think of that.  Would just 
modifying the ROOT/WEB-INF/web.xml work?  I expected that I needed to modify 
the entire site's defaults since I didn't think that the root would suffice, 
but now that I think about it, your suggestion does sound much more logical.

FYI, I did run a couple of tests to see if the site-wide would conflict with 
an individual application, but it seems that the individual application's 
settings will override it - however, only if specified.  If not specified, 
then I can indeed forsee additional confusion occuring.

Will take another look at that tomorrow.

Thanks,

Eric




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


Re: Custom 404 for non-existant contexts?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Eric,

Eric B. wrote:
| "Caldarale, Charles R" <Ch...@unisys.com> wrote in message
|
news:2828B04F0113CD468E6D1D51DF4362A404CC2281@USEA-EXCH2.na.uis.unisys.com...
|>> Subject: Custom 404 for non-existant contexts?
|>>
|>> Is there a way to create a custom 404 error page for Tomcat
|>> for non-existant context paths?
|
|> What happens if you declare a custom error page for the ROOT (default)
|> webapp?
|
| Yeah - that's pretty much the only thing I managed to figure out.  I
updated
| the conf/web.xml file to include
|    <error-page>
|       <error-code>503</error-code>
|       <location>/error/maintenance.html</location>
|     </error-page>

Note that you have modified the default web.xml for all webapps, and not
the ROOT webapp. This may have unintended consequences for other web
applications.

| and put the /error/maintenance.html in the ROOT directory.

If you have a ROOT directory, why not use ROOT/WEB-INF/web.xml instead
of hacking the site-wide defaults?

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkeqP4kACgkQ9CaO5/Lv0PDiegCfd31lEnt3hmfoV2oxBAgKAOPv
idMAn1MpbGilhVIDY86VC2dszx36ncvQ
=kjW0
-----END PGP SIGNATURE-----

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


Re: Custom 404 for non-existant contexts?

Posted by "Eric B." <eb...@hotmail.com>.
"Caldarale, Charles R" <Ch...@unisys.com> wrote in message 
news:2828B04F0113CD468E6D1D51DF4362A404CC2281@USEA-EXCH2.na.uis.unisys.com...
>> Subject: Custom 404 for non-existant contexts?
>>
>> Is there a way to create a custom 404 error page for Tomcat
>> for non-existant context paths?

>What happens if you declare a custom error page for the ROOT (default)
>webapp?

Yeah - that's pretty much the only thing I managed to figure out.  I updated 
the conf/web.xml file to include
   <error-page>
      <error-code>503</error-code>
      <location>/error/maintenance.html</location>
    </error-page>


and put the /error/maintenance.html in the ROOT directory.

Of course, the ugly part about this is that a) /error/maintenance.html is 
now accessible through my root app (unless otherwise protected), and I need 
to have a separate ROOT/error/maintenance.html for each individual Tomcat 
instance.  I was hoping to be able to centralize the error msgs (as in 
httpd), but didn't have any success.  I tried using a symlink to point my 
error/ folder to a central location, but Tomcat didn't follow the link.

Not the prettiest soln, but functional.  Would be nice if I could make it 
nicer tho.

Thanks,

Eric





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


RE: Custom 404 for non-existant contexts?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: news [mailto:news@ger.gmane.org] On Behalf Of Eric B.
> Subject: Custom 404 for non-existant contexts?
> 
> Is there a way to create a custom 404 error page for Tomcat 
> for non-existant context paths?

What happens if you declare a custom error page for the ROOT (default)
webapp?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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