Today encountered a problem, the updated JSP page deployed to the server under Tomcat, the page does not take effect. Finally know that there is no clear reason for Tomcat's work directory, now to learn about Tomcat's related principles
Tomcat's principle is that when a browser accesses a page, Tomcat turns the JSP page into a. java file in the work directory. For example, convert index.jsp into Index_jsp.java, and then compile into Index_jsp.class file, finally tomcat through the ClassLoader class to load this index_jsp.class class into memory, the client work.
Tomcat periodically scans the container for JSP files, reads the attributes of each file, and when a JSP file is found to be changed (the file's last modification time is different from the last scan), Tomcat converts and compiles the JSP file again. But the Tomcat scan is not real-time, which is why the JSP page changes to wait a few minutes clock such as JSP page entry into force. For immediate effect, it is recommended that the contents of the work directory be purged immediately after the JSP page has been modified. In addition, in the Tomcat container, the compiled Java files (such as Index_jsp.java) have only 64kb of compilation, so when you migrate the JSP into the Tomcat container in the other container, you will encounter a situation where the JSP file will not compile. Therefore, it is recommended that the JSP business logic to write a separate class, in the JSP page by calling the class in the static method to execute, and the JSP in JS extracted out into a separate JS implementation.