Java EE – for web What is the meaning of false in the servlet definition in XML?
It seems that servlet's web XML has an element named
<enabled>false</enabled>
This can be placed in the service definition
<servlet> <servlet-name>example</servlet-name> <servlet-class>com.example.TestServlet</servlet-class> <load-on-startup>100</load-on-startup> <enabled>false</enabled> </servlet>
Is the ability of the servlet to process requests enabled? I noticed that even if I set enabled to false, the init method of servelt will be called Searching through servlet spec PDF does not provide an explanation of the meaning of < enabled > In fact, I can't even find the string < enabled > in the servlet 3.0 specification
Solution
From java servlet 3.0 specification, 8.2 3 see the PDF:
Editor: This is another article on the exact topic: how to make sure that servlet is not loaded?
Edit 2: (place a summary of the following comments here) in Tomcat 7 (version 7.0.25), it seems that the servlet will initialize, but the request for its URL pattern will respond with status code 503 (sc_service_unavailable)