tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <Craig.McClana...@eng.sun.com>
Subject Re: AW: Servlet mapping
Date Mon, 14 Aug 2000 17:48:19 GMT
"Schmitt, Christian" wrote:

> Craig,
> yes, I tried that and that's working as well. But I probably didn't make
> myself very clear.
> What I want to achieve is that the servlet is found and called regardless of
> the URL i.e.:
> http://localhost/cs/some/directory/info  --> OK that works with the mapping
> below.
> But what if I also want to find the servlet here:
> http://localhost/cs/a/totally/different/directory/info
> OK, now I could map the servlet to this directory as well, but I don't want
> to :-)
>
> I read the Java Servlet Specificiation and in chapter 10.1 (page 47) it
> says:
> 1. The servlet container will try to match the exact path of the request to
> a servlet.
> 2. The container will then try to recursively match the longest path prefix
> mapping.
>
> I thought that this means that if I map a servlet like this:
> <servlet-mapping>
>   <servlet-name>info</servlet-name>
>   <url-pattern>/info/*</url-pattern>
> </servlet-mapping>
>
> the servlet should be called whenever the container finds 'info/*' in the
> request.
>

No, prefix matching always starts from the beginning of the context-relative
part of the request URI.  The "longest path prefix" stuff is to define the
rules when you have two mappings like this:

    /some/* --> Servlet A
    /some/directory/* --> Servlet B

If you are mapping request "/some/directory/plus/even/more/stuff", this will
get mapped to Servlet B because "/some/directory/*" is longer than "/some/*".

>
> Puzzled,
> Christian
>

Craig



Mime
View raw message