Jetty
  1. Jetty
  2. JETTY-936

DefaultServlet doesn't dispatch to welcome files that are servlets rather than static resources

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.1.14
    • Fix Version/s: 6.1.17
    • Component/s: Servlet
    • Labels:
      None
    • Number of attachments :
      1

      Description

      DefaultServlet seems to handle everything about welcome files. However it only checks if the path appended with the welcome file name is a static resource, not if its a handled servlet mapping.

      I discovered this when I compiled all the jsps in an app, including index.jsp, and deleted the source jsps..... the welcome files stopped working.

      One possible solution would be to check the pathMap in ServletHandler for the appended path and dispatch to it if present. However I'm not sure how to get to the ServletHandler from the DefaultServlet. Maybe there's a better way?

      I imagine this is a problem in 7 also but haven't checked.

        Activity

        Hide
        David Jencks added a comment -

        I don't think this is an adequate solution. If there is an exact match to a servlet mapping, that should be used, you shouldn't need a flag to get this. The flag should only apply for *.jsp type servlet mappings.

        Show
        David Jencks added a comment - I don't think this is an adequate solution. If there is an exact match to a servlet mapping, that should be used, you shouldn't need a flag to get this. The flag should only apply for *.jsp type servlet mappings.
        Hide
        Jan Bartel added a comment -

        David,

        I can see the motivation for your proposed solution, but it looks a bit hacky to me.

        Greg, can you please comment?

        regards
        Jan

        Show
        Jan Bartel added a comment - David, I can see the motivation for your proposed solution, but it looks a bit hacky to me. Greg, can you please comment? regards Jan
        Hide
        Greg Wilkins added a comment -

        David,

        Jetty-6 has always required that the welcome FILE exists before triggering. With the addition of the welcomeServlets flag, we can now match welcome servlets even if the file does not exist.

        I think having the flag apply to servlets as a whole makes a lot more sense rather than to suffix matching or to a specific *.jsp pattern. It means the flag is a switch between traditional Jetty behaviour and the vagueness of the servlet spec behaviour.

        I really think the only debate should be what is the default value for this flag. My preference is for jetty-6, the default is welcomeServlets=false, but for jetty-7 onwards we change to welcomeServlets=true as the default?

        Show
        Greg Wilkins added a comment - David, Jetty-6 has always required that the welcome FILE exists before triggering. With the addition of the welcomeServlets flag, we can now match welcome servlets even if the file does not exist. I think having the flag apply to servlets as a whole makes a lot more sense rather than to suffix matching or to a specific *.jsp pattern. It means the flag is a switch between traditional Jetty behaviour and the vagueness of the servlet spec behaviour. I really think the only debate should be what is the default value for this flag. My preference is for jetty-6, the default is welcomeServlets=false, but for jetty-7 onwards we change to welcomeServlets=true as the default?
        Hide
        Greg Wilkins added a comment -

        Actually there is a definite bug with this.

        The servlet matching should be done on the complete path in context and not just the welcome fragment.

        Show
        Greg Wilkins added a comment - Actually there is a definite bug with this. The servlet matching should be done on the complete path in context and not just the welcome fragment.
        Hide
        Greg Wilkins added a comment -

        r5522 fixes the servlet matching problem, adds a test harness and optimized so that:
        + servlet handler was only looked up once
        + servlet entries are scoped with path in context
        + servlet entries are checked that they are not the default servlet
        + only a single iteration through the welcome files - so path add done only once per pattern
        + the path in context is returned, so the caller does not need to add the context path again.

        Show
        Greg Wilkins added a comment - r5522 fixes the servlet matching problem, adds a test harness and optimized so that: + servlet handler was only looked up once + servlet entries are scoped with path in context + servlet entries are checked that they are not the default servlet + only a single iteration through the welcome files - so path add done only once per pattern + the path in context is returned, so the caller does not need to add the context path again.

          People

          • Assignee:
            Greg Wilkins
            Reporter:
            David Jencks
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: