Is there any method or API that I can use so that whenever I deploy a new WAR file, a part of code should execute or perhaps when Tomcat starts, the respective servlet should s
You can include a "ContextListener" in web.xml. An instance of this class would be created when Webb application WAR is about to be deployed/started.
This code can start a thread that would keep running till app is deployed.
Example : http://www.javafaq.nu/java-example-code-233.html