File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes About servlet-mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "About servlet-mapping" Watch "About servlet-mapping" New topic

About servlet-mapping

Jack Lau
Ranch Hand

Joined: Aug 30, 2002
Posts: 168
Hello All,

I create an TestServlet and add the following code into web.xml

I expected both (/TestServlet and /test/Testxxx) of them can map to TestServlet but only /TestServlet work properly.

Could anyone tell me why /test/Testxxx cannot (but /test/Test* work)?

Thanks in advance!!
[ June 21, 2004: Message edited by: Jack Lau ]
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3323

Let's see what the spec says:

SRV.11.2 Specification of Mappings
In theWeb application deployment descriptor, the following syntax is used to define
� 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.

so, use either




but not



Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Exam 1Z0-810: Upgrade to Java SE 8 Programmer Study Guide and Quiz
Jack Lau
Ranch Hand

Joined: Aug 30, 2002
Posts: 168
Thank you very much

I agree. Here's the link:
subject: About servlet-mapping
It's not a secret anymore!