I have servlet in my web.xml but i don’t want my application to load it, one would think that if we don’t want that servlet to load then what is the purpose of putting it there, actually I need to have it in web.xml because am deploying two instances of application and on one instance I need to have that servlet and on another I do not want to have it and I’m using only one web.xml, am not sure how this can be done.
Here is my web.xml:
<servlet>
<servlet-name>StartServlet</servlet-name>
<servlet-class>com.web.startServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
I cannot put -ve value because then container would invoke this servlet randomly, kindly correct me here and advise of an proper way to do it.
You can disable the Servlet (which means that it will not be reachable through defined url-pattern mapping) by using
enabledelement in web.xml.Servlets 3.0 specification in Chapter 8.2.3 Assembling the descriptor from web.xml, web-fragment.xml and annotations says:
The
enabledelement is defined in XML Schema here and can be found as a child element of the<servlet>element.