Why can we see the changes made to the jsp when the page is refreshed? why not for a servlet?
Servlets are compiled classes that we load somewhere in WEB-INF, but copy them to our base workstation to run them. Until they are changed in the THAT location, the changes will not be reflected, and this will only happen when the server is restarted.
In the case of a jsp page, When Tomcat is prompted to execute a JSP, it compares the modified date of the JSP file with the modification time of the compiled class corresponding to that JSP, and if it is more recent, it is recompiled on the fly before executing it.
source to share
The other answers are correct, however you asked, "Why do we have to restart the server?" You do not. You just need a server to use the updated file, not fetch it from the cache. There are several ways to do this. For Tomcat 8.0.21 it seems to be true that saving changes to web.xml causes the server to use files rather than cache.
The fastest way I've found to do this is add space, save, remove space, save again. Also, I've done this in a significant area, like in url tags.
source to share