tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Todd <james.t...@eng.sun.com>
Subject Re: repost: contextPath + servletPath + pathInfo = requestURI?
Date Sat, 13 Nov 1999 02:03:17 GMT

when i read, and re-read, the spec i'm not so sure a "/*" mapping is
a violation. the fact that it begins with a "/" and ends with "/*" and
the is one and only one slash in the string (ie it intersects the sets)
does not, in my humble interpretation, violate the spec measurably.

i believe i added a bit'o code to support both "/" and "/*" (should
be in RequestMapper) and at the time didn't have a real heart-ache
in doing so.

interestingly enough when i first joined a team i had a bit of a problem
supporting both "" and "/" requests. this was before the 2.2 pattern
matching stuff but as such i still suspect the "/" pattern match. of the
three:

    ""
    "/"
    "/*"

i like the latter especially when coupled with the "will match the longest
request" spec statement.

hmmmmm ...

- james

Hans Bergsten wrote:

> Geoff Soutter wrote:
> >
> > >I'm trying to get tomcat working with a servlet mapped to / (actually /* as
> > >per the 2.2 spec), in the default context.
>
> I'm not sure "/*" is a valid pattern. To replace the default servlet the correct
> pattern is just "/" based on the last rule below:
>
>   10.2 Specification of Mappings
>   In the web application deployment descriptor, the following syntax is used to
>   define mappings:
>   * A string beginning with a '/' character and ending with a '/*' postfix is
>     used as a path mapping.
>   * A string beginning with a '*.' prefix is used as an extension mapping.
>   * All other strings are used as exact matches only
>   * A string containing only the '/' character indicates that servlet specified
>     by the mapping becomes the "default" servlet of the application.
>
> > >anyway, consider the situation where you map a servlet to /*, and you have
> > a
> > >requestURI = "/blah"
> > >
> > >the current tomcat does the following:
> > >
> > >contextPath = "/"
> > >servletPath = null
> > >pathInfo = "/blah"
> > >
> > >which adds as per the spec as "/ "+ null + "/blah" = "/null/blah" (if you
> > >take the spec as java code, which I presume was the intention).
> > >
> > >For testing, I've made tomcat do the following:
> > >
> > >contextPath = "/"
> > >servletPath = ""
> > >pathInfo = "/blah"
> > >
> > >which adds as per the spec as "/" + "" + "/blah" = '//blah' (which is still
> > >wrong). However, this works for my test servlet as it was written for 2.0
> > >and doesn't make use of contextPath.
> > >
> > >Problem is, _both_ of these options seem to violate the spec! Any ideas on
> > >what the correct solution is?
> > >
> > >Also, the spec states that both contextPath and servletPath must start with
> > >a "/" character. This clause seems to clash with the clause about adding in
> > >the case where you are mapping a servlet to /*
>
> My interpretation of the spec is that it should result in this (for the default
> context):
>
>   contextPath = ""
>   servletPath = "/blah"
>   pathInfo = null
>
> The spec says:
>
>   5.4 Request Path Elements
>   The request path that leads to a servlet servicing a request is composed of many
>   important sections.
>   The following elements are obtained from the request URI path and exposed via the
>   request object:
>   * Context Path: The path prefix associated with the ServletContext that this servlet
>     is a part of. If this context is the "default" context rooted at the base of the
>     web server's URL namespace, this path will be an empty string. Otherwise, this path
>     starts with a '/' character but does not end with a '/' character.
>   * Servlet Path: The path section that directly corresponds to the mapping which
>     activated this request. This path starts with a '/' character.
>   * PathInfo: The part of the request path that is not part of the Context Path or
>     the Servlet Path.
>
> --
> Hans Bergsten           hans@gefionsoftware.com
> Gefion Software         http://www.gefionsoftware.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message