Why Tomcat Server does not needs restart if changes are done in servlet and JSP?
Tomcat is capable of adding/modifying classpath to Web Application classloader at runtime. Tomcat will be having their custom Classloader implementation which allows them to add the classpaths at runtime.a new classloader is created for the Servlet/JSP with Application classloader as parent classloader. And the new classloader will load the modified class again.
It is always best to reload the entire application incase changes are done to servlet. If you were simply to reload one class, in isolation, you might break dependencies or miss some initialization steps. Therefore, it’s much safer to reload the entire application clicking deploy option in tomcat server.JSPs on the other hand, when properly coded, shouldn’t have anything in them by markup text. So reloading a single JSP, without reloading the entire app, should be safe. By default, tomcat is started in development mode, which means JSP-derived servlets recompiled when a change is detected.
In the web.xml you need to set the below config
<servlet> . . <!-- Add the following init-param --> <init-param> <param-name>development</param-name> <param-value>true</param-value> </init-param> . . . </servlet>
In the Server.xml reloadable should be set to true
<Context path="/simple" docBase="webapps/simple" debug="0" reloadable="true" ></Context>
More on how CustomClass loader works for Hot Deployment here