Hmmm... I'll take a look at that, but I think our answers are correct, so I'm not sure what Tomcat is doing. Here's the reason:
The servlet mapping for DeployTestTwo is a URL pattern /fooStuff/bar, which is an exact match.
So the /fooStuff/bar/blue.do does not match that URL pattern exactly. If DeployTestTwo was mapped to /fooStuff/bar/*, then you are correct, and /fooStuff/bar/blue.do would have been the closest match. But since /fooStuff/bar is an *exact match* URL pattern, the /fooStuff/bar/blue.do matched to the URL pattern /fooStuff/*
Does that make sense? So while it is true that the longest match will win, this only works when you are not talking about an *exact* match. In an exact match URL pattern, like /fooStuff/bar, only an exact match will work.
Hmmmm... can you check this again in Tomcat? I'm going to do the same...
Probably I have made some mistake, but as that code is not infront of me where I tested before. But now here in my home, I have tested this on three servers, Tomcat 4.0, Tomcat 5.0 and Weblogic 8.1, and it is following the *exact* URL rules. So answer is correct. But I would like to finish this thread until tomorrow morning where I would be able to see the previous code that made me to write this error. I think the server there was something 4.x.
Thanks to both of you for help, I will write more on it tomorrow after looking at other code.
Cowgirl and Author
posted 15 years ago
This stuff is always tricky to test, because you often won't get any errors about what is in your DD, and because different versions of Containers do not always follow the spec *exactly*. What is in the book has all been tested on Tomcat 5, but even slight variations in versions of Tomcat can sometimes show different results. Ahhh... for the good old days when all you had to do was run javac and java to test everything