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 Three question about  Servlet Mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Three question about  Servlet Mapping" Watch "Three question about  Servlet Mapping" New topic

Three question about Servlet Mapping

Hai Lin
Ranch Hand

Joined: May 23, 2004
Posts: 79
Hi Folks,
Suppose there's a web application called colorapp.
then in the web.xml,


The book SCWCD exam study kid said "URI /colorapp/red will match RedServlet."
But I have doubt: The url-pattern is /red/*, that means at least URI should end with "/", so why /colorapp/red can match it? If we say the last "/" in url-pattern doesn't matter, then take a look the following mapping,

The URI /colorapp/blue doesn't match BlueServlet, That means the last "/" in the servlet mapping is very important!
So, my confusion is that
1) why the first mapping /colorapp/red is fine?
2) how about /colorapp/red/?
3) any "?" used in the url-pattern mapping?

Greatly appreciate your reply.
dick dijk

Joined: Jan 19, 2004
Posts: 5
/red/* in the servet mapping means : match anything that starts with "/red".
Therefore "/colorapp/red" matches this pattern.

I agree. Here's the link:
subject: Three question about Servlet Mapping
It's not a secret anymore!