tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: What can <url-pattern> accept?
Date Sun, 17 Aug 2008 11:14:04 GMT
Guojun Zhu wrote:

Unfortunately, it seems that the servlet API allows only this in 
<url-pattern> specs :
- 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.

In other words, "/admin/*.do" is not a valid way to match what you want, 
since it will match only "/admin/*.do", literally.

For 20 years at least, there have been 2 widely-used pattern-matching 
variations in existence :
- the "file glob" kind of pattern, where "*" anywhere matches any number 
of characters and ? anywhere matches one character
- regular expressions
Why the designers of the servlet API found it useful or necessary to 
invent yet their own different way of matching wildcards, and a rather 
brain-dead one at that, is beyond me.
But so it seems to be.

This being said, it seems that there exists a "servlet filter" which 
allows much more flexibility.  I have not tried it myself yet, but I 
have seen a lot of nice things written about it.
Check out :


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message