So these kinds of questions can best be answered by reading the Servlet specifications, which you
can find here.
The appropriate chapter is SRV 11: Mapping Servlets to Requests. If you read section SRV.11.2 you will see:
So when you have the URL mapped to:
/test*
That would be an unmatched pattern since the * would not be a wildcard, but must be an exact match. So let's change your question to ask:
"When I make a request to /test/my.jsp, which will be chosen between a
JSP with the path under the context root of /test/my.jsp versus a servlet mapped to /test/*?"
To answer this we look at section SRV.11.1 which says:
So in the case of a JSP at:
/ContextRoot/test/my.jsp
versus a Servlet mapped to
/test/*
First try Rule 1, and if there isn't a specific match to /test/my.jsp then that fails.
Then try Rule 2... by looking through the mapped URLs, /test/my.jsp matches the /test/* URL so that servlet gets called.
Only if the requested URL didn't match a specific mapping in the web.xml would Rule 3 apply and let the JSP servlet get executed. But because Rule 2 applies before Rule 3, those URLs you map in the web.xml will take precedence over extension-mapped URLs, such as JSPs.
[ December 31, 2008: Message edited by: Steve Luke ]