| Author |
Url Matching Algorithm Used By Tomcat for web.xml
|
Jarryd Folino
Greenhorn
Joined: Apr 28, 2011
Posts: 2
|
|
I am trying to set up a simple java program that can do the following:
* Takes in a ' given url' such as '/places/australia'
* Takes in a list of URL mappings such as ["*.do", *jsp, "/places", "/places/aust"]
I want to do this to investigate exactly which given URL's will match against the servlet and filter mappings given in a web.xml file. My initial guess was to use the standard Java Pattern and Matcher classes as per below:
However when I ran the code I got the following exception:
This would imply that the standard java regex classes are not used for matching the URL's in web.xml.
Does anyone know of the class library tomcat or a similar container uses to determine if a given url matches the web.xml mappings?
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1041
|
|
You get the exception because the character "*" has a special meaning in regex. If you want to match you can use ".do".
Note that when you are using regex it will look for all matches in a string and URL mapping works quite differently. Read the Servlet specs 2.4 section SRV.11.1 Use of URL Paths for more information.
Regards,
Frits
|
 |
 |
|
|
subject: Url Matching Algorithm Used By Tomcat for web.xml
|
|
|