Is it possible to turn on and off the particular servlets from web.xml ((ie) Disable or enable particular servlet in web.xml) externally without updating the data manually in web xml?
Thanks for the reply, I need to disable or enable the servlets depending on the input data for example, if its a production eniv, I need few servlets to be available and for test i doesn't require them, so basically i need to update the servlets in web xml to support my configuration.
Is there any possibility of using load-on-startup values and setting this?
Perhaps you could do this with a front controller and context attributes that you can set through some servlet, but it would require your entire web application to be rewritten to use that front controller.
What would it mean to "disable" a servlet? Would that require sending a 404 error response to any requests for that servlet?
Anyway keeping track in the application context of which servlets were "disabled", along with a filter to enforce that disabling, might also be a solution.
No, It does not need to send a 404 message, the scenario here is, I have a bunch of servlets in web xml file and depending on the input data my web xml should be modified such that only servlets required for my app based on the input should be present in the web xml and other servlets in the web xml should be disabled.
Sounds like this a build-time issue not a run-time issue. If you are building for the test environment, create a web.xml that includes the extra servlets. For a production build, leave them out of the web.xml.
Yeah thanks for the info, but i was trying to find whether there is a possibility of having one web xml and the servlets related to the app in it as like i have now, and to turn off the servlets depending on the environment selected, without doing it manually.
But guess from your answers, there is no option to do so, Am i right?
Let's assume that to "turn off" a servlet means to not include it in the web.xml file -- that seems the most likely thing for it to mean based on what I've seen so far.
And let's assume that "doing it manually" means "using a text editor to modify the web.xml file" -- although it could mean a lot of other things.
Then no, you don't have to "do it manually". You could write an application which transformed a master version of the web.xml file into a subset suitable for your various applications.