Hello group,
I am using David Bridgewater's book to prepare for the exam. One of the Self
Test answers claims that the url-pattern "/" is a "catch all"
pattern answer to Chapter 4 Question 5). The same is claimed on page 198 about the pattern used for a LogFilter class.
However, when I try it out in a filter-mapping, the pattern "/" only works when exactly matched. In the
servlet specs I can only find that the url-pattern work the same as for servlets.
For servlets the rules are as follows (please, correct me if I am wrong):
Take the request URI and strip the context path. On what is left, do the following:
Try find an exact match among the url-patterns that contain no '*'. If not found: try to match among the url-patterns that end in '/*' (e.g, /*, /somedir/*, /somedir/somesubdir/*) If multiple matches are found, take the longest. If not found: try to match among the url-patterns that start with '*.' (e.g, *.jsp, *.html) If still not found, use url-pattern '/' if present. The goal is to find exactly one servlet. However, with filters all the matching filters must be executed. If I try this out in
Tomcat 5.5.17, this is indeed the case, but the "default" ('/') is apparently not considered a match, as the mapped filter is only executed if I request a URL of the form
<context path>/ (e.g.
http://localhost:8084/MyApp/). So, am I forgetting something here or should I be sending an erratum to the author?
Thanks for any help, regards,
Jan van Mansum.