This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In theWeb application deployment descriptor, the following syntax is used to define mappings:
* A string beginning with a / character and ending with a /* suffix is used for path mapping. * A string beginning with a *. prefix is used as an extension mapping. * A string containing only the / character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null. * All other strings are used for exact matches only.
The pattern /* will force everything through your servlet. The pattern / will make your servlet the default servlet for the app, meaning it will pick up every pattern that doesn't have another exact match.
After getting this wrong like 2 dozen times over the last ten years, I want to say this post is probably the best answer *except* that the spec has one other provision that is relevant. JSPs are implicitly mapped to the "*.jsp" mapping. So, if you use the mapping that puts everything through your servlet (/*), you basically can't use JSPs (cuz any time you forward or redirect to a JSP, the request is going to boomerang back to your servlet).