• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Url Matching Algorithm Used By Tomcat for web.xml

 
Jarryd Folino
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2173
57
Android Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However when I ran the code I got the following exception: Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0 *.do

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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic