Chris et. al., Thank you for the direction. I created my own servlet which loads without error. Here is how I've configured it:
<servlet> <servlet-name>HttpResponseAdjuster</servlet-name> <servlet-class>bla.bla.tomcat.ReturnNotAvailableServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>HttpResponseAdjuster</servlet-name> <url-pattern>/foo/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>HttpResponseAdjuster</servlet-name> <url-pattern>/Testing/*</url-pattern> </servlet-mapping> 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 <ch...@christopherschultz.net> To: Tomcat Users List <users@tomcat.apache.org> Date: 06/15/2012 05:05 PM Subject: Re: Modify HTTP status returned by stopped context -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kyle, On 6/15/12 12:30 PM, kharp...@oreillyauto.com 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> I > 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk/bsAwACgkQ9CaO5/Lv0PAdOgCfdMi3jVdXL/mQ1qtBkZG9bSAt TN0Ani5zPBO2eVCjHn+SGwbOBu93OXmP =2vo8 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org -- 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: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org