DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3760>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3760

When forwaring from one servlet to another, path info may get lost

           Summary: When forwaring from one servlet to another, path info
                    may get lost
           Product: Tomcat 3
           Version: 3.2.3 Final
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Servlet
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Symptom: When forwaring from one servlet to another, path info may get lost
Tomcat version: 3.2.3

It gets lost under these two circumstances:

1. It is forwarded to /servlet/* (no mapping in server.xml) and this
serlvet has not been accessed so far. On the second request, path info
is transmitted correctly.

2. It is forwarded to /someurl and in web.xml there is a mapping
for /someurl (not /someurl/*) to a servlet.

It works, however, if the request is forwarded to /someurl and there
is a mapping for /someurl/* in web.xml.

That 2 does not work may be acceptable, although I think it should
work (does somebody know, what the spec says?), but 1 is not
acceptable in my eyes.

Diagonistics:

The reasons, why it does not work, are different:

1. On the first request, the dynamic wrapping for
/servlet/SecondServlet is not present. So in SimpleMapper1.contextMap

            Container container =(Container)map.getLongestPrefixMatch(  host,
                                                                        path );
returns a default container. This leads to erasure of path info in
SimpleMapper1.fixRequestPaths:
        case Container.DEFAULT_MAP:
            s=path.substring( ctxPLen );
            pathI= null ;

If this request was not created by forwarding, this would be solved by
InvokerIntercetor.requestMap:
        // Now we need to fix path info and servlet path
    // [cut irrelevant code]
        int secondSlash=servletPath.indexOf("/", prefixLen );
        if ( secondSlash > -1) {
            servletName = servletPath.substring(prefixLen, secondSlash );
            newPathInfo = servletPath.substring( secondSlash );
        } else {
            servletName = servletPath.substring( prefixLen );
        }
but this does obviously not work, as servletPath does not contain the
path info, because it was a forward request.

2. Path info is removed by SimpleMapper1.contextMap calling
fixRequestPaths, because container is of type PATH_MAP.

Possible Solution:

In RequestDispatcherImpl (which starts the forwarding process) add a
special attribute "isForwarded" to
request. SimpleMapper1.fixRequestPaths should check for this attribute
before "fixing" path info, because this has already been done by its
invocation for the original servlet.

Is there a chance, you will fix this (I can supply a diff) and
release something like 3.2.3p1 or do I have to live with a patched
tomcat?

Reply via email to