4 Replies Latest reply on Oct 25, 2002 7:49 AM by gregwilkins

    Jetty HttpServletRequest.getServletPath() problem

    ultracode

      I recently moved a servlet .war file from Tomcat 4.0.1 to JBoss 3.0.2/Jetty. This caused the application to break, mainly because HttpServletRequest.getServletPath() seems to be returning the wrong information.

      When I invoke my servlet with the URL http://localhost:8080/pending/servlet/pending/login on the two platforms, I get the following from the HttpServletRequest object

      Tomcat 4:
      ContextPath: /pending
      PathInfo: /login
      QueryString: null
      RequestURI: /pending/servlet/pending/login
      ServletPath: /servlet/pending

      JBoss/Jetty:
      ContextPath: /pending
      PathInfo: /pending/login
      QueryString: null
      RequestURI: /pending/servlet/pending/login
      ServletPath: /servlet

      Judging by the Servlets 2.3 APIdocs, it seems to me like Jetty has a bug with getPathInfo() and getServletPath(), and that Tomcat has it right. Is this a known issue with Jetty?
      -Eric

        • 1. Re: Jetty HttpServletRequest.getServletPath() problem
          gregwilkins

          I assume that you have a servlet named "pending"?

          I'm not sure if the spec is that clear what these
          methods should report for a named servlet dispatch.

          Jetty is reporting the returns for a match of the
          invoker servlet at /context/servlet/*, and I don't
          think the spec is very clear if this is correct or
          not.

          We use a request dispatcher to go from the invoker servlet to the named servlet. The spec does not say if the path methods should change for such a dispatch and we leave them as they are.

          So I think your webapp is in a very ambiguous part of
          the spec. But I will investigate further and ask the JSR 154 and watchdog folks what they think.

          Probably we will change to match the tomcat behaviour.

          cheers

          • 2. Re: Jetty HttpServletRequest.getServletPath() problem
            mcmagnus

            Any news regarding this?

            I had the same problem moving Slide from Tomcat to JBoss. I patched Jetty's behaviour and now it works ok. But did you find any conclusive specs from JSR 154 and the "watchdog folks"?

            Magnus

            • 3. Re: Jetty HttpServletRequest.getServletPath() problem
              gregwilkins


              No i did not get any additional feedback - so I guess
              we will have to follow tomcat.

              What was the patch that you did? Was it a hack or generally applicable? Can you email it to gregw@mortbay.com.

              thanks

              • 4. Re: Jetty HttpServletRequest.getServletPath() problem
                gregwilkins

                Here is an updated Invoker servlet that should work on Jetty 4.1 and Jetty 4.2. It should fix the problem (but a more efficient fix will come eventually).

                cheers