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):
If a servlet is disabled using the enabled element introduced in the web.xml then the servlet will not be available at the url-pattern specified for the servlet.
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)
I can't find it anywhere indeed, apart from the XSD. If it still handles requests (check that), then I guess it is added there for future use, or to let containers decide what to do with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With