tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <>
Subject Re: repost: contextPath + servletPath + pathInfo = requestURI?
Date Fri, 12 Nov 1999 06:02:51 GMT
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

  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
Gefion Software

View raw message