aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes URL Pettern source Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "URL Pettern source" Watch "URL Pettern source" New topic
Author

URL Pettern source

Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
Hi ranchers,

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 ?
Milind Patil
Greenhorn

Joined: Oct 19, 2003
Posts: 26
First line of HTTP request is,

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
Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
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 ]
albert Jin
Greenhorn

Joined: Jul 21, 2010
Posts: 5
Hi Milind!
Where did you specify 'examples' of http://example.com/examples/status/synopsis in the application project?
I am looking for where to setup the application name as default like 'examples'.
Thanks,
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1660
    
  25

Hi Albert,

Welcome to javaranch!

You are replying to an old thread, so you might not get an answer from the original poster. Maybe we can help you out. Are you planning to go for the certification?

Do you want to know how URL mapping works? Or where it is done? The mapping of an URL to a servlet is done in the web.xml in the <url-pattern> of the <servlet-mapping> element.

Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URL Pettern source