Seems that web.xml for a servlet has an element called
<enabled>false</enabled>
that can be put in the servelt definition like so
<servlet>
<servlet-name>example</servlet-name>
<servlet-class>com.example.TestServlet</servlet-class>
<load-on-startup>100</load-on-startup>
<enabled>false</enabled>
</servlet>
Does enabled refer to the ability of the servlet to process requests? I noticed that even if I set enabled to false the init method of the the servelt gets called. Searching through the servlet spec pdf did not provide an explanation of the meaning of <enabled> in fact I could not even find the string <enabled> in the servlet 3.0 spec.
From the Java Servlet 3.0 specification, 8.2.3 section 3 (see the pdf):
Edit: Here’s another post on this exact topic: How to make sure that servlet is not loaded?
Edit 2: (putting summary from comments below in here)
In Tomcat 7 (as of 7.0.25) it appears that the Servlet will initialize but requests to its url-pattern will respond with a status code 503 (
SC_SERVICE_UNAVAILABLE)