tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Modify HTTP status returned by stopped context
Date Mon, 18 Jun 2012 19:52:17 GMT
Chris et. al.,

Thank you for the direction.  I created my own servlet which loads without
error.  Here is how I've configured it:




Unfortunately, when I stop the "foo" context, tomcat is still returning the
default HTTP 404 page.  It doesn't appear to give any consideration to the
servlet mapping in my ROOT context.  Unless I've configured something
wrong, it appears the desired behavior (to look for /Context first, then a
ROOT servlet with mapping of /Context/*) isn't happening.

You'll notice I setup another servlet-mapping called /Testing/*.  "Testing"
is NOT a context.  When I go to myserver:8080/Testing my servlet handles
the request and does what I desire (HTTP 503).  To reiterate, my version of
tomcat is 6.0.24.  Perhaps the logic we're relying on wasn't introduced
until later?  Or maybe I'm missing a configuration option at a higher level
to send failed requests to search the ROOT context for mappings?

I'm open to any ideas or alternate solutions at this point.

Thank you.

Kyle Harper

From:	Christopher Schultz <>
To:	Tomcat Users List <>
Date:	06/15/2012 05:05 PM
Subject:	Re: Modify HTTP status returned by stopped context

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>

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:

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

This communication and any attachments are confidential, protected by Communications Privacy
Act 18 USCS  2510, solely for the use of the intended recipient, and may contain legally
privileged material. If you are not the intended recipient, please return or destroy it immediately.
Thank you.

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

View raw message