You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by yhs <yh...@altavista.com> on 2001/08/21 01:31:26 UTC

custom 404s from a servlet ?

Hi guys,
  does anyone know how i can modify tomcat's configuration files so my 404's can be invoked
from a servlet ? i.e. i want http://localhost:8080/someweirdlink?x=foo to be redirected
to http://localhost:8080/servlet/my404servlet?x=foo if someweidrlink doesnt exist...
similarly if servlet abc doesnt exist http://localhost:8080/servlet/abc should also
be redirected to http://localhost:8080/servlet/my404servlet ...
I'd like to keep everything else the same..i.e. jsps. html and servlets all remaining
the same but all site wide 404's in every directory be redirected to the same servlet.
im running tomcat 3.2.3...
Thanks.
-Ys-

Find the best deals on the web at AltaVista Shopping!
http://www.shopping.altavista.com

Re: custom 404s from a servlet ?

Posted by Bill Barker <wb...@wilshire.com>.
I'm sure that other people are going to flame this thread as off-topic, but
the answer is to call

response.sendError(HttpServletResponse.SC_NOT_FOUND,"someweirdlink doesn't
exist");
return;



----- Original Message -----
From: "yhs" <yh...@altavista.com>
To: <to...@jakarta.apache.org>
Sent: Monday, August 20, 2001 4:31 PM
Subject: custom 404s from a servlet ?


> Hi guys,
>   does anyone know how i can modify tomcat's configuration files so my
404's can be invoked
> from a servlet ? i.e. i want http://localhost:8080/someweirdlink?x=foo to
be redirected
> to http://localhost:8080/servlet/my404servlet?x=foo if someweidrlink
doesnt exist...
> similarly if servlet abc doesnt exist http://localhost:8080/servlet/abc
should also
> be redirected to http://localhost:8080/servlet/my404servlet ...
> I'd like to keep everything else the same..i.e. jsps. html and servlets
all remaining
> the same but all site wide 404's in every directory be redirected to the
same servlet.
> im running tomcat 3.2.3...
> Thanks.
> -Ys-
>
> Find the best deals on the web at AltaVista Shopping!
> http://www.shopping.altavista.com
>
>


Re: custom 404s from a servlet ?

Posted by Dmitri Colebatch <di...@bigpond.net.au>.
yep - have a look at <error-page> (I think) in web.xml...  The servlet
spec outlines its use (http://java.sun.com/products/servlet).

hth
cheesr
dim

On 20 Aug 2001, yhs wrote:

> Hi guys,
>   does anyone know how i can modify tomcat's configuration files so my 404's can be invoked
> from a servlet ? i.e. i want http://localhost:8080/someweirdlink?x=foo to be redirected
> to http://localhost:8080/servlet/my404servlet?x=foo if someweidrlink doesnt exist...
> similarly if servlet abc doesnt exist http://localhost:8080/servlet/abc should also
> be redirected to http://localhost:8080/servlet/my404servlet ...
> I'd like to keep everything else the same..i.e. jsps. html and servlets all remaining
> the same but all site wide 404's in every directory be redirected to the same servlet.
> im running tomcat 3.2.3...
> Thanks.
> -Ys-
> 
> Find the best deals on the web at AltaVista Shopping!
> http://www.shopping.altavista.com
>