servlet-spec
  1. servlet-spec
  2. SERVLET_SPEC-42

Clarify wether @WebServletAnnotation can complete a preliminary servlet registration

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      The <servlet> web.xml element was changed to remove the requirement to specify a <servlet-class>. This results in what is referred to as a "preliminary servlet registration". The specification/javadocs describe how the ServletContext.addServlet() methods can be used to complete the registration, but does not mention whether or not a WebServletAnnotation can be used to do so.

      Eg
      web.xml contains:
      <servlet>
      <servlet-name>Foo</servlet-name>
      </servlet>

      FooServlet.java contains:
      @WebServlet(urlPatterns =

      {"/","/test/*"}

      , name="Foo", initParams=

      {@WebInitParam(name="fromAnnotation", value="xyz")}

      )
      public class FooServlet extends HttpServlet

      Is the servlet registration for "Foo" updated with classname "FooServlet" after processing the annotation?

        Activity

        janbartel created issue -
        Rajiv Mordani made changes -
        Field Original Value New Value
        Assignee Rajiv Mordani [ mode ]
        Hide
        Rajiv Mordani added a comment -

        Yes the idea is that a descriptor can override any information specified in the annotation (look at the rules for merging in the spec.) So to answer your question as long as metadata-complete is not set - the annotation and descriptor combine to give the effective declaration.

        Show
        Rajiv Mordani added a comment - Yes the idea is that a descriptor can override any information specified in the annotation (look at the rules for merging in the spec.) So to answer your question as long as metadata-complete is not set - the annotation and descriptor combine to give the effective declaration.
        Rajiv Mordani made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Rajiv Mordani added a comment -

        Also in the javadocs for Registration.java it clearly says - "A Registration object whose

        {@link #getClassName}

        method returns null is considered <i>preliminary". If a servlet is annotated, the getClassName will not return null and hence will not be considered preliminary.

        Show
        Rajiv Mordani added a comment - Also in the javadocs for Registration.java it clearly says - "A Registration object whose {@link #getClassName} method returns null is considered <i>preliminary". If a servlet is annotated, the getClassName will not return null and hence will not be considered preliminary.

          People

          • Assignee:
            Rajiv Mordani
            Reporter:
            janbartel
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: