Just to make sure you understand servlet mappings, here’s one more little example. Don’t skim—look closely at both the mapping and the requests. (In this mini “Be the Container”, the answers are at the bottom of the opposite page, so don’t peek.)
BE the Container
Which servlet will the Container choose?
Mappings in the DD
<servlet> <servlet-name>Two</servlet-name> <servlet-class>foo.DeployTestTwo</servlet-class> </servlet> <servlet-mapping> <servlet-name>Two</servlet-name> <url-pattern><b>/fooStuff/bar</b></url-pattern> </servlet-mapping> <servlet> <servlet-name>Four</servlet-name> <servlet-class>foo.DeployTestFour</servlet-class> </servlet> <servlet-mapping> <servlet-name>Four</servlet-name> <url-pattern><b>/fooStuff/bar/*</b></url-pattern> </servlet-mapping>
Requests:
http://localhost:8080/test/fooStuff/bar/ Container choice:
http://localhost:8080/test/fooStuff/bar Container choice: