How to force update jsp file in war in Tomcat

A common problem in deploying WAR to Tomcat server is the JSP file update may not reflect on the server. It can be a headache sometimes.

In Tomcat 7, any java class changes won't need restart the server, Tomcat will automatically detect the WAR file timestamp and redeploy it if necessary. But this is not the case for JSP file, the redeploy doesn't include JSP file.

Restart Tomcat server can't solve it neither, actually, the file actually used by Tomcat is the compiled binary of the JSP file, and they are cached, not in your application's folder, but somewhere else like CATALINA_HOME\apache-tomcat-7.0.30\work\Catalina\localhost.

The only surefire way I know is delete the application folder in webapps directory and copy the latest WAR file to webapps folder, Tomcat will detect it and start deploy it in a second.

You can look at this page for how to copy the WAR file automatically after building in Gradle:Gradle Cargo tomcat deployment problem.

If you are testing a small demo project for example a helloworld project, this method may work for you, but if the project is big, deploy in this way is inefficient.