tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Modify HTTP status returned by stopped context
Date Fri, 15 Jun 2012 21:58:36 GMT
Hash: SHA1


On 6/15/12 12:30 PM, wrote:
> I attempted to do what you prescribed but I am running into a snag
> and can't figure out what I've done incorrectly.
> I have a context, we'll call it /foo
> In my ROOT web application (/) I created a servlet with a mapping
> of /foo/* like so: <servlet> 
> <servlet-name>foo-404-change</servlet-name>
> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>

don't think you'll want to use the DefaultServlet for this purpose.

Try defining your own servlet that merely returns a 503 response. This
is better done as a servlet than a JSP, anyway.

> <servlet-mapping> <servlet-name>foo-404-change</servlet-name> 
> <url-pattern>/foo/*</url-pattern> </servlet-mapping>
> I've created a simple JSP to respond with a 503.  We'll call it 
> change-status.jsp.  If I call this page, it works fine.  However,
> when I stop the context /foo, and attempt to reach /foo/whatever, I
> still get a 404 as if my servlet isn't even trying to handle the
> request.
> I thought maybe I needed to specify an error page so that ROOT
> would know what to do with a 404, so I setup the following in the
> ROOT web app's web.xml: <error-page> <error-code>404</error-code> 
> <location>/change-status.jsp</location>

Don't map 404: just map /foo/* to your foo-404-change servlet and
leave it at that.

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message