Chris,

First, thanks again for your help.  I appreciate it.

To answer your questions:

"Where did you configure this? Which webapp's web.xml?"
In the ROOT context (/).  I'm on Ubuntu 10.04 with defaults,
so /var/lib/tomcat6/webapps/ROOT/WEB-INF/web.xml

"Yes, the longest match should win."
We keep saying "the longest match should win", but looking at the
configuration it seems illogical.  If I configure the following:
ROOT context:  /foo/*  (My special servlet)
foo context:  /  (DefaultServlet)

It would  seem like the ROOT context would always try to respond first,
since it has the longest matching URL pattern.  Even if you extrapolate
from the context name you're left comparing these two things:
ROOT context:  /foo/*
foo context:  /foo/

Based on my testing this isn't the case.  So is it accurate to say tomcat's
logic is (or we expect it to be):
1.  Look for a context that matches the URL base pattern.
2.  If not found, search all contexts for servlets with URL patterns that
can service the request and select the one with the longest match.


As for testing on 6.0.35 and 7.0.28, yea I can do that.  I'll set all that
up and submit a bug report if I can't get the intended behavior to work.
But this bring up another point:  wouldn't it be more accurate for tomcat
return HTTP Status Code 503 for a context that has been deployed but is in
the stopped/errored state?  Strictly speaking, it isn't "not found" but
rather "unavailable".  If there is a better forum/group to have this
discussion with let me know.

I'll report back with my test results.  Thanks!

Kyle Harper




From:   Christopher Schultz <ch...@christopherschultz.net>
To:     Tomcat Users List <users@tomcat.apache.org>
Date:   06/18/2012 07:49 PM
Subject:        Re: Modify HTTP status returned by stopped context



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kyle,

On 6/18/12 3:52 PM, kharp...@oreillyauto.com wrote:
> Thank you for the direction.  I created my own servlet which loads
> without error.  Here is how I've configured it:

Where did you configure this? Which webapp's web.xml?

> <servlet> <servlet-name>HttpResponseAdjuster</servlet-name>
> <servlet-class>bla.bla.tomcat.ReturnNotAvailableServlet</servlet-class>
>
>
<load-on-startup>1</load-on-startup>

You don't need to load this on startup if you don't want to: the
servlet will be initialized when necessary.

> </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.

Yes, the longest match should win.

> 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?

Assuming you have everything configured as described, then your
expected behavior is also what I'd expect.  Please test with latest
6.0 which is 6.0.35. If that doesn't work, please also test with
7.0.28 (freshly minted this weekend) and let us know if you have more
success.

If it does not work with 6.0.35 or it does not work with 7.0.28, can
you create a simple test case (ROOT.war + some other WAR w/overlapping
URI spaces) and create a Bugzilla ticket for it (or 2, if the bug
exists in both versions)?

- -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/fyvkACgkQ9CaO5/Lv0PBkvwCgiZ9fDieTRdPSJTkrphxRn7Yi
CoUAoJy5RTwqSwSLCJe5hrnpmw747k4O
=5ESc
-----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

Reply via email to