[SERVLET_SPEC-42] Clarify wether @WebServletAnnotation can complete a preliminary servlet registration Created: 04/Jul/12  Updated: 25/Feb/13  Resolved: 14/Feb/13

Status: Resolved
Project: servlet-spec
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: janbartel Assignee: Rajiv Mordani
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


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.

web.xml contains:

FooServlet.java contains:
@WebServlet(urlPatterns =


, 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?

Comment by Rajiv Mordani [ 18/Jul/12 ]

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.

Comment by Rajiv Mordani [ 25/Feb/13 ]

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.

Generated at Tue Oct 06 19:04:51 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.