tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geoff Soutter" <>
Subject contextPath + servletPath + pathInfo = requestURI?
Date Tue, 02 Nov 1999 06:41:21 GMT
Hi there,

I'm trying to get tomcat working with a servlet mapped to / (actually /* as
per the 2.2 spec), in the default context.

It sort of works (thanks Gonzo :-) after a couple of fixes to
core.RequestMapper.getPrefixMatch() . However, I need clarification on how
this really ought to work before I submit a patch.

The 2.2 PR2 spec says:

"It is important to note that the following equation is always true:
requestURI = contextPath + servletPath + pathInfo. In all cases a servlet
developer must be able to access these portions of the path, add them
together as shown, and obtain the same result as returned by

[ Note: As discussed a while back on this list, this isn't strictly true
since pathinfo and servlet path (and I presume contextPath) are supposed to
be % decoded and requestURI is not. So it's more like contextPath +
servletPath + pathInfo = percent_decoded( requestURI ). But thats another
story... ]

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 /*



View raw message