Tomcat's work Directory

Source: Internet
Author: User

1 when using Tomcat as a Web server, the deployed programs are under WEBAPPS, these programs are compiled programs (the classes that are published to Tomcat's project are compiled into. Class before they are published, the source file is not published, but the JSP here is not compiled). Tomcat has a work directory, which contains the page cache, access to the JSP will be compiled (from the work into the Catalina after the localhost site folder items, we can see those JSP pages will be compiled into a servlet file, The next time you visit, you can directly run the Servlet class to respond to the response page to the client, so some bloggers said the first visit will be slower, because the newly published page in the first person to visit, will first compile into a servlet file, so slow, once compiled, So unless the JSP page is modified, otherwise the next access to run the servlet directly can respond to the user, so fast, the compiled files will be stored in the work directory. And the directory that Tomcat displays, will look for the compiled JSP corresponding 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 in the Tomcat runtime can not show the modified traces. This is the time to delete the corresponding project folder under the work directory and restart Tomcat.

2 after the host name is configured in the Server.xml file under Tomcat's Conf configuration folder, the folder of the site name is set up under the Catalina folder under Conf and under the Catalina file under work, and every release of the project will be put in. will also be recorded in the Catalina folder under Conf file.

Recently found that many netizens like the work directory of Tomcat is called the cache, in fact, it is not very appropriate, work directory is only tomcat working directory, that is, Tomcat to convert JSP to class file working directory, That's why it's called the work directory, not the cache directory.
Jsp,tomcat's work is that when a browser accesses a JSP page, Tomcat converts the JSP page into a. java file in the work directory, such as converting index.jsp to Index_jsp.java file and then compiling to Index_ Jsp.class file, the last Tomcat container loads the Index_jsp.class class into memory through the ClassLoader class, responding to the client's work.

Tomcat will periodically slightly describe the JSP file in the container, read the properties of each file, and when a JSP file is found to change (the file's last modification time is not the same as the last one), Tomcat will convert, compile the JSP file. But the bit of Tomcat is timed not real-time, which is why the JSP file changes need a few minutes of time to wait for the modified JSP to take effect. Of course, in order to take effect immediately, many of the old-timers will recommend to modify the JSP page immediately after the work directory to clear the file.

In addition, in the Tomcat container, the converted Java file (for example: index_ Jsp.java) is compiled with a maximum support of 64k only, so in other containers in the JSP porting to the Tomcat container will encounter large JSP file will not compile, so we recommend that the JSP business logic to write a separate class, in the JSP by calling this class static method to execute, and JSP page in the JS extraction Come out and put it in a separate JS file.

Problem fields:  
    How to get Tomcat to automatically update class issues. &NBSP
Solution:  
First,  
Create a stand-alone profile under the Tomcat path installed. &NBSP
For example:  
to create a file: d:\tomcat5.5\conf\catalina\localhost\testapp.xml 

Content is:  
< Context docbase= "D:\Tomcat5.5\webapps\testapp" reloadable= "true" path= "/testapp" workdir= "work\catalina\localhost\" TestApp "> 
</context> 

Restart tomcat 

Two,  
Direct in Tomcat profile conf/ Server.xml Add the following:  
<context docbase= "D:\Tomcat5.5\webapps\testapp" reloadable= "true" path= "/testapp" Workdir= "Work\catalina\localhost\testapp" > 
</context> 
Note that <engine name= "Catalina" defaulthost= "localhost" > Label add;  
Restart Tomcat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.