I am very confusing the url pattern syntax, and evaluation of spefic URL to a url pattern. I need answer for following queries 1.types of URL pattern, what are they 2.any rules are there in the url pettern 3. syntax errors of url pettern 4. which url will win among similar URL petterns
any link also great helpful to me.
SCJP 5 |SCWCD 5| Started thinking about Web Services ?
POST /status/synopsis HTTP/1.0 (Method) (Request URI) (Protocol)
Every character in a pattern must match the corresponding character in the URL path exactly, with two exceptions. 1. At the end of a pattern, '/*' matches any sequence of characters from that point forward. 2. The pattern *.extension matches any file name ending with extension.
No other wildcards are supported, and an asterisk at any other position in the pattern is not a wildcard.
The pattern <url-pattern>/</url-pattern> always matches any request that no other pattern matches
Now final thing is exact match. It means whatever coming in the request URI should match URL pattern
[ August 19, 2008: Message edited by: Milind Patil ]
Milind B. Patil - SCJP-1.4, SCWCD-5.0, SCBCD-5.0
Joined: Jul 14, 2008
Thanks Milind Patil,
I also got some content in the Mikalai Zaikin notes
The servlet-mapping defines a mapping between a servlet and a URL pattern. The path used for mapping to a servlet is the request URL from the request object minus the context path and the path parameters. The URL path mapping rules below are used in order. The first successful match is used with no further matches attempted: 1. The container will try to find an exact match of the path of the request to the path of the servlet. A successful match selects the servlet. 2. The container will recursively try to match the longest path-prefix. This is done by stepping down the path tree a directory at a time, using the '/' character as a path separator. The longest match determines the servlet selected. 3. If the last segment in the URL path contains an extension (e.g. .jsp), the servlet container will try to match a servlet that handles requests for the extension. An extension is defined as the part of the last segment after the last '.' character. 4. If neither of the previous three rules result in a servlet match, the container will attempt to serve content appropriate for the resource requested. If a "default" servlet is defined for the application, it will be used. The container MUST use case-sensitive string comparisons for matching. In the Web application deployment descriptor, the following syntax is used to define mappings: -> 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.
[ August 20, 2008: Message edited by: Chintu sirivennela ]