aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Url Matching Algorithm Used By Tomcat for web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Url Matching Algorithm Used By Tomcat for web.xml" Watch "Url Matching Algorithm Used By Tomcat for web.xml" New topic
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
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1518
    
  22

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
 
subject: Url Matching Algorithm Used By Tomcat for web.xml
 
Similar Threads
Regex question
Regular Expression pattern search is throwing "java.lang.IllegalStateException"
Url Matching Algorithm Used By Tomcat for web.xml
Please help me check this regex
is there anything like isNum() ?