I've got a Tomcat 5.0.14, IIS 5.1, jk2 setup.

My workers2.properties file has a [uri:/foo/*] set up to forward requests to
a worker.

I've got the worker service set up to handle the requests with the following
server.xml context:

  <Context path="/foo" docBase="C:\foo" debug="0" reloadable="false"/>

I've got a servlet implementing a WebDAV server with a WEB.XML file that
contains the following:

  <servlet-mapping>
    <servlet-name>foo</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>

It all seems to work fine. All requests with a URI prefix of "/foo" get to
my servlet great except for one small hitch. If a request comes in with
specifying a resource URI of exactly "/foo", the request does not get to my
servlet. Instead, a 302 redirect response is generated specifying a location
of "http://bar/foo/"; (note the trailing slash). If a request specifying a
resource URI of "/foo/" comes in, it gets forwarded to my servlet.

My problem is that there are a great many WebDAV clients out there that
can't handle the 302 response and treat it as an error. The main culprits
are the Win2K and WinNT Web Folder clients. The WinXP client seems to handle
it fine, but it seems really inefficient for each request sent to "/foo" to
be redirected to "/foo/".

I can get around this by specifying path="" in the <Context> tag, but then
the context path of the servlet request is empty, making it awkward for the
servlet to figure out what portion of the request URI is context and what is
the rest.

I got the source code for the worker process and ran it in a debugger to see
if I could find the source of the problem. What it came down to was the
'internalMapWrapper' method of the org.apache.tomcat.util.http.mapper.Mapper
class. This method has the following snippet of code:

  int length = context.name.length();
  if (length != (pathEnd - pathOffset)) {
      servletPath = pathOffset + length;
  } else {
      // The path is empty, redirect to "/"
      path.append('/');
      mappingData.redirectPath.setChars
          (path.getBuffer(), path.getOffset(), path.getEnd());
      path.setEnd(path.getEnd() - 1);
      return;
  }

When the context is "/foo" and the path is "/foo", the redirectPath of
mappingData is set to "/foo/" and the 'service' method of the
org.apache.coyote.tomcat5.CoyoteAdapter class then calls
response.sendRedirect instead of calling the servlet container.

I was wondering if anyone knew of a way for me to keep my context path at
"/foo" and not have requests with a URI of "/foo" generate a response of 302
and instead get passed through to my servlet.

Thanks,

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to