1 when using Tomcat as a Web server, the program deployed under WebApps, these programs are compiled programs (the classes published into the Tomcat project will be compiled into a. Class before it is published, the source file is not published, but the JSP here is not compiled). Tomcat has a work directory that contains the cache of pages, the JSP that is accessed is compiled (items from work into Catalina, such as the localhost site folder, and we can see that those JSP pages are compiled to be servlet files. , the next time you visit, you can directly run the Servlet class to respond to the client page, so some blog said the first visit will be slower, because the newly published page in the first person access, will be compiled into a servlet file, so slow, once compiled good, Then, unless the JSP page is modified, the next access directly runs the servlet to respond to the user, so the compiled file will be stored in the work directory. The directory that Tomcat displays will look for the compiled JSP's class file from this cache. So when the work directory is emptied, the process will be new.
Sometimes there is a problem, that is, the modified page will not show the modified traces when Tomcat is running. This time delete the corresponding project folder in the work directory and restart Tomcat.
2 after configuring the host name in the Server.xml file under the Conf configuration folder of Tomcat, the folder of the site name is established under the Catalina folder under Conf and under the Catalina file under work, each time the project is published, It will also be recorded in the configuration file of the Catalina folder under Conf.
Recently found that many users like the Tomcat work directory in the things called cache, in fact, it is not very appropriate, working directory is only Tomcat directory, that is, Tomcat to convert the JSP to a class file working directory, That's why it's called the work directory, not the cache directory.
Jsp,tomcat works by when a browser accesses a JSP page, Tomcat translates the JSP page into a. java file in the work directory, such as converting index.jsp to a Index_jsp.java file, and then compiling the Index_ Jsp.class file, the last Tomcat container loads the Index_jsp.class class into memory through the ClassLoader class to respond to the client's work.
Tomcat periodically strokes the JSP files in the container, reads the properties of each file, and when a JSP file is found to be changed (the last modification time of the file is not the same as the last stroke), Tomcat will re-convert and compile the JSP file. But Tomcat's stroke is timed and not real-time, which is why JSP files can take a few minutes to change and wait for the modified JSP to take effect. Of course, in order to take effect immediately, many old-timers would recommend clearing the files in the work directory immediately after modifying the JSP page.
In addition, in the Tomcat container, the converted Java files (for example: index_ Jsp.java) Compile maximum support only 64k, so in other containers in the JSP porting to the Tomcat container will encounter a large JSP file can not compile, it is recommended that the business logic in the JSP to write a separate class, in the JSP by invoking the static method of the class to execute, and the JSP page JS extract And put it in a separate JS file.
Problem domain:
How to get Tomcat to automatically update the class problem.
Solution:
One
Create a stand-alone configuration file under the Tomcat path that you installed.
For example:
Create a file: D:\Tomcat5.5\conf\Catalina\localhost\testapp.xml
The contents are:
<context docbase= "D:\Tomcat5.5\webapps\testapp" reloadable= "true" path= "/testapp" workdir= "work\catalina\ Localhost\testapp ">
</Context>
Restart Tomcat
Two
Add the following directly to the Tomcat configuration file Conf/server.xml:
<context docbase= "D:\Tomcat5.5\webapps\testapp" reloadable= "true" path= "/testapp" workdir= "work\catalina\ Localhost\testapp ">
</Context>
Note is added under <engine name= "Catalina" defaulthost= "localhost" > tag;
Restart Tomcat
Tomcat's work directory.