Tomact's work Catalogue

Source: Internet
Author: User

1. When using Tomcat as a Web server, the deployed program is under WebApps, which are compiled programs (classes that are included in the project published to Tomcat, 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 the host name is configured in the Server.xml file in the Conf configuration folder of Tomcat, the site name folder is created 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 scans the JSP files in the container periodically, 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 scan), Tomcat re-converts and compiles 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

"Reproduced in Others"
Top

Tomact's work Catalogue

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.