servlet-spec
  1. servlet-spec
  2. SERVLET_SPEC-12

Clarify the path prefix mapping in Section 12.1

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      Section 12.1 states that prefix mapping is done by stepping down the path tree on directory at a time. However, given a path "/foo/", it does not mention how to deal with the trailing "/". This is significant given that "/foo" (no trailing slash) matches "/foo/" as shown later in that chapter (which is a bit confusing if "/" is naively converted in to a regexp).

      The use of "/" with the intended semantics is somewhat misleading since it can match any number of paths, including zero. Ant uses "*" to match arbitrary number of directories (including none). IMO, a better syntax for servlet mapping would be:

      /.../* => /.../** (path prefix)
      (ii) .ext => //.ext (extension mapping)

      For example,

      (1) match(/a/**, /a/b/c/d) = (/a, /b/c/d)
      (2) match(/a/**, /a) = (/a, null) (since ** matches 0 directories)

      and

      (3) match(/*/.ext, /a/b/c.ext) = (/a/b/c.ext, null)

      Changing the syntax would obviously be backward incompatible, but perhaps an alternate syntax could be consider in future revisions of the spec.

        Activity

        Santiago Pericas-Geertsen created issue -
        Hide
        gregwilkins added a comment -

        While I agree that the path mapping is a bit strange, I'm loath to change it now.... unless there is significant support to do so.

        If there is to be a change in the mapping, then another issue that needs to be fixed is the inability to form a pattern to match the ROOT of a webapp, since "/" is the default mapping. Also the fact that "/" has different semantics to "/*" is confusing as they both match the same requests (in the absence of any suffix matches).

        Show
        gregwilkins added a comment - While I agree that the path mapping is a bit strange, I'm loath to change it now.... unless there is significant support to do so. If there is to be a change in the mapping, then another issue that needs to be fixed is the inability to form a pattern to match the ROOT of a webapp, since "/" is the default mapping. Also the fact that "/" has different semantics to "/*" is confusing as they both match the same requests (in the absence of any suffix matches).
        Rajiv Mordani made changes -
        Field Original Value New Value
        Assignee Rajiv Mordani [ mode ]
        Rajiv Mordani made changes -
        Tags servlet matching path prefix extension mapping extension future_release mapping matching path prefix servlet
        Ed Burns made changes -
        Assignee Rajiv Mordani [ mode ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Santiago Pericas-Geertsen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: