Nic Ferrier wrote:
>
> How should the path mapping rules be interpreted?
>
> If I implement the path mapping rules fully (see note below) should
> a directory mapping for root receive all requests for files?
>
> For example:
>
> - map a servlet X to "/"
> - map a servlet Y to ".html"
> - request a file "/file.html"
>
> Should X receive the request for /file.html?
Yes, that's how I read the specification.
According to the Servlet API 2.1 specification:
* You can map a servlet to just one URL.
For example, you can specify that a particular servlet is only called by requests
from the file URL /feedback/index.html.
* You can map a servlet to any URL that begins with a certain directory name.
For example, if you map a servlet to the URL /catalog, requests from
/catalog/, /catalog/garden, and /catalog/housewares/index.html
would also map to the servlet. However, requests from /catalogtwo or
/catalog.html would not.
* You can map a servlet to any URL that ends with a certain file name extension.
For example, you can map a request for any file whose name ends in .thtml to a
particular servlet. If you use both file name extension mapping and directory
mapping in your servlet engine, design the engine so that the file name resolution
takes place after the directory name resolution fails.
[...]
So, as you said, directory mappings should be tested before file name
extensions.
I can't find it now, but I believe it's also true that exact URL mappings should
be tested before directory mappings, and for multiple directory mappings you should
pick the one that most closely maps the URL, i.e. with
- map a servlet X to "/"
- map a servlet Y to ".html"
- map a servlet Z to "/file.html"
- map a servlet A to "/catalog"
- map a servlet B to "/catalog/foo"
- request "/file.html" should be served by Z
- request "/foo.html" should be served by X
- request "/catalog/foo/bar" should be served by B
It would be nice if James Davidson can confirm this.
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html