SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 75 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

Figures 2??“7 and 2??“8 show the results of invoking TestServlet5 with these
URLs, respectively.

Test5
coreservlets.TestServlet5


Test5
*.urlTest5

Figure 2??“7 TestServlet5 invoked with http://localhost/deployDemo/foo/bar/
baz.urlTest5.
Figure 2??“8 TestServlet5 invoked with http://localhost/deployDemo/
foo.urlTest5.
Chapter 2 ?–  Controlling Web Application Behavior with web.xml 50
Matching Overlapping Patterns
When mapping a servlet to a URL, the specification does not allow the same value of
url-pattern to appear twice within the same web.xml file. Thus, there can never
be an overlap between two patterns that map exact matches. However, if one or more
servlet mappings use ???*???, an overlap could occur.
Compliant servers are required to use the following rules to resolve these overlaps.
??? Exact matches are handled first. Thus, if /foo/bar and /foo/*
were both url-pattern entries, the first would take precedence for
a request URL of http://host/webAppPrefix/foo/bar. Similarly,
/foo/bar.html would win over *.html for an incoming URL of
http://host/webAppPrefix/foo/bar.html.
??? Directory mappings are preferred over extension mappings.
Thus, if /foo/* and *.html were both url-pattern entries, the
first would take precedence for a request URL of http://host/
webAppPrefix/foo/bar.


Pages:
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87