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 Fri, 15 Jun 2012 16:30:36 GMT

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:



The above configuration loads fine (servlet starts up no problem).

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

If I go to http://myserver:8080/not-a-real-page" the 404 triggers the
location specified, and my JSP correctly returns a blank page with an HTTP
status of 503.

If I go to http://myserver:8080/foo/not-a-real-page" while the context /foo
is running, I get a 404 as expected.

If I go to http://myserver:8080/foo/some-other-fake-page" while the
context /foo is stopped, I still just get a 404.

I'm not sure where to go from here, and would greatly appreciate any ideas
you (or anyone else) have.

Kyle Harper

From:	Mark Thomas <>
To:	Tomcat Users List <>
Date:	06/14/2012 03:19 PM
Subject:	Re: Modify HTTP status returned by stopped context

On 14/06/2012 20:37, wrote:
> Hello,
> I am running multiple web applications on a tomcat server.  When a
> to a context in the stopped state is made, tomcat is returning 404 "not
> found" rather than 503 "unavailable".  Is it possible to change this
> behavior in any way?  Obviously I can't just modify _all_ HTTP 404
> responses to 503.  Just those which are coming from a context in the
> stopped state.

Assume the context in question is /foo

In the ROOT web application add a servlet with a mapping of /foo/*

The servlet should just return a 503 (or any other error code)

This works because the mapping rules require the longest match to the
context be considered first. While /foo is running, requests will be
mapped to the /foo context and the servlet in the ROOT web application
is ignored. When /foo is not running, the request is mapped to the
servlet in the ROOT web app.

This obviously won't work for stopping the ROOT web app.



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