Geronimo
  1. Geronimo
  2. GERONIMO-3921

getContextRoot() returns forward slash rather than empty string for apps deployed to root context

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0, 2.0.1, 2.0.2, 2.1, 2.1.1, 2.2
    • Fix Version/s: 2.0.3, 2.1.1, 2.2
    • Component/s: Tomcat
    • Security Level: public (Regular issues)
    • Labels:
      None

      Description

      An app deployed to the root context should have "" returned by getContextRoot() - On Tomcat, we are returning "/".

      dcherk wrote:
      > I am deploying my war file into the root context with the following
      > deployment plan:
      > ----------
      > <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0"
      > xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2"
      > xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
      > xmlns:security="http://geronimo.apache.org/xml/ns/security-1.2">
      > ...
      > <context-root></context-root>
      > ...
      > </web-app>
      > ----------
      >
      > The application starts up properly, and responds on http://localhost, as
      > expected.
      >
      > However, when I examine request.getContextPath(), I get a forward slash:
      > "/".
      >
      > This is incorrect, as far as I can tell. According to the API
      > (http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html#getContextPath()):
      > ----------
      > For servlets in the default (root) context, this method
      > [HttpServletRequest.html.getContextPath()] returns "".
      > ----------
      >

        Issue Links

          Activity

          Hide
          Jay D. McHugh added a comment -

          Jetty was not an issue.

          They did not have the same check for apps deployed to the root context.

          Show
          Jay D. McHugh added a comment - Jetty was not an issue. They did not have the same check for apps deployed to the root context.
          Hide
          Jay D. McHugh added a comment -

          Has anyone checked to confirm that this works in Jetty?

          If not, I'll check in the next few days and close this issue.

          Show
          Jay D. McHugh added a comment - Has anyone checked to confirm that this works in Jetty? If not, I'll check in the next few days and close this issue.
          Hide
          Jay D. McHugh added a comment -

          Jarek,

          I just checked the Jetty 'wrapper' around the getContext method and it does not have the same
          check for the first character not being a '/'.

          So it should be functioning correctly.

          Show
          Jay D. McHugh added a comment - Jarek, I just checked the Jetty 'wrapper' around the getContext method and it does not have the same check for the first character not being a '/'. So it should be functioning correctly.
          Hide
          Donald Woods added a comment -

          Committed to branches/2.0 as Rev638438

          Show
          Donald Woods added a comment - Committed to branches/2.0 as Rev638438
          Hide
          Jarek Gawor added a comment -

          Jay,

          How does Jetty handle this? I think Jetty checks/modifies the contextPath in the same way as Tomcat used to, so it might need a fix also.

          Show
          Jarek Gawor added a comment - Jay, How does Jetty handle this? I think Jetty checks/modifies the contextPath in the same way as Tomcat used to, so it might need a fix also.
          Hide
          Jay D. McHugh added a comment -

          Fixed it too fast.
          Forgot the parens on the length function to the fix on trunk (branches/2.1 was correct).

          Sending plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
          Transmitting file data .
          Committed revision 637232.

          Show
          Jay D. McHugh added a comment - Fixed it too fast. Forgot the parens on the length function to the fix on trunk (branches/2.1 was correct). Sending plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Transmitting file data . Committed revision 637232.
          Hide
          Jay D. McHugh added a comment -

          Fix committed to branches/2.1

          Sending plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
          Transmitting file data .
          Committed revision 637227.

          Show
          Jay D. McHugh added a comment - Fix committed to branches/2.1 Sending plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Transmitting file data . Committed revision 637227.
          Hide
          Jay D. McHugh added a comment -

          Fix committed to trunk.

          Sending plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
          Transmitting file data .
          Committed revision 637223.

          Show
          Jay D. McHugh added a comment - Fix committed to trunk. Sending plugins/tomcat/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Transmitting file data . Committed revision 637223.

            People

            • Assignee:
              Jay D. McHugh
              Reporter:
              Jay D. McHugh
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development