by Kishan » Mon Feb 11, 2013 4:59 am
This is really nice question.
Yes, you can specify init parameters for servlet either through web.xm or servlet annoations in java code itself. When you are specifying in the java code and if you are making any changes you have to recompile the program and redploy with new compiled class. Where as in web.xml change has to restart the server is sufficient.
If you have any configuration changes so often web.xml is good option.
Most of the times In reality, application configuration seperated through database/service/properties file etc... This will give more flexibility to update the configuration to immediately effect in all the servers rather than changing directly in the server.