A detailed description of Tomcat files

Source: Internet
Author: User

    • Tomcat background
      Since JSP was released, a variety of JSP engines have been introduced. After completing the development of GNUJSP1.0, Apache Group began to consider developing a JSP server that could provide Web services directly on the Sun's JSWDK basis, while also supporting Servlets, so that Tomcat was born. Tomcat is an important subproject in the Jakarta project, which was selected by editors of Javaworld Magazine as the most innovative Java product of the 2001, and it is also the official recommended servlet and JSP container for sun. As a result, it is becoming more and more popular with software companies and developers. The latest specifications for Servlets and JSPs can be implemented in a new version of Tomcat. Second, Tomcat is completely free software that anyone can download freely from the Internet. The combination of Tomcat and Apache is quite perfect.

    • Tomcat Directory

        |---Bin Tomcat: Store startup and shutdown tomcat scripts;

        |---Doc: storing tomcat documents;
         |---Lib/japser/common: library file (JARS) for Tomcat operation required,
         |---src: The source code for Tomcat;
         |---Webapps:tomcat's main Web publishing directory (including application examples);
         |---Work: Store the JSP generated by the class file,

    • Tomcat class loading

Bootstrap ($JAVA _home/jre/lib/ext/*.jar)
System ($CLASSPATH/*.class and the specified jar)
Common (classes,lib,endores three sub-directories under $CATALINA _home/common)
Catalina (Classes and Lib directories under $CATALINA _home/server/are only visible to Tomcat)
&shared (the classes and LIB directories and $catalina_home/lib directories under the $CATALINA _home/shared/) are visible only to the Web application, not to Tomcat WEBAPP ($WEBAPP/ web-inf/* only visible to the Web App Classes/*.class Lib/*.jar)
The order in which classes and resources are loaded is:
1,/web-inf/classes---> 2,/web-inf/lib/*.jar-->3,bootstrap-->4,system-->5, $CATALINA _home/common/ Classes-->6, $CATALINA _home/common/endores/*.jar-->7, $CATALINA _home/common/lib/*.jar-->8, $CATALINA _ Home/shared/classes-->9, $CATALINA _home/shared/lib/*.jar

    • Server.xml Configuration Introduction:

The basic configuration information in this file is described below, and for more specific configuration information, refer to the Tomcat documentation:
Server
1. Port specifies a ports, which is responsible for monitoring the request to close Tomcat
2. Shutdown specifies the command string to send to the port (default is 8005)
Service
1. Name Specifies the service (Catalina)
Connector (indicates a connection between the client and the service):
1. Port specifies the port number to be created on the server side and listens for requests from the client at this fracture (8080)
2. Minprocessors the number of threads that are created to process requests when the server starts
3. Maxprocessors the maximum number of threads that can be created to process requests
4, Enablelookups If true, you can call Request.getremotehost () to make a DNS query to obtain the actual hostname of the remote client, if False does not make DNS query, but return its IP address
5. Redirectport Specifies the port number that the server is redirecting after it receives an SSL transfer request when it is processing an HTTP request (8443)
6, Acceptcount Specifies the number of requests that can be placed in the processing queue when all the threads that can be used to process the request are used, and requests that exceed this number will not be processed
7. ConnectionTimeout specifies the number of times to time out (in milliseconds) (20000)
Engine (representing the request processor in the specified service, receiving and processing requests from connector):
1. DEFAULTHOST Specifies the default host name for processing requests, which is at least the same as the Name property value of one of the host elements
Context (representing a Web application):
1. The path of the DocBase application or the path where the war file is stored
2. Path represents the prefix of the URL for this Web application, so the requested URL is http://localhost:8080/path/****
3, reloadable This property is very important, if true, Tomcat will automatically detect changes in the application's/web-inf/lib and/web-inf/classes directories, automatically load new applications, We can change the application without having to restart Tomcat

<context path= "" docbase= "/usr/local/serve/tomcat/webapps/hx-webapp" reloadable= "true" crossContext= "true"/>

Host (represents a virtual host):
1. Name Specifies host name
2, appBase application Basic directory, that is, the directory to store the application
3, Unpackwars If True, Tomcat will automatically unzip the war file, otherwise, run the application directly from the war file

Logger (indicates log, debug, and error messages):
1, className Specifies the class name used by Logger, this class must implement the Org.apache.catalina.Logger interface
2. prefix specifies the prefix of the log file
3. suffix specifies the suffix of the log file
4, timestamp If true, the log file name to join the time, for example: Localhost_log.2001-10-04.txt
Realm (the database that holds the user name, password, and role):
1, className Specifies the class name used by realm, this class must implement the Org.apache.catalina.Realm interface
Valve (functionally similar to logger, whose prefix and suffix attributes are explained in the same way as in logger):
1. CLASSNAME specifies the class name that Valve uses, such as using the Org.apache.catalina.valves.AccessLogValve class to record access information for an application
Directory (Specify the location where the log file is stored):
1, the pattern has two values, the common method records the remote host name or IP address, the user name, the date, the first line of the requested string, the HTTP response code, the number of bytes sent. Combined way more value than common way record

    • Introduction to Web. XML configuration:

1, the Error file settings

<error-page>

<error-code>404</error-code>

<location>/notFileFound.jsp</location>

</error-page>

<error-page>

<exception-type>java.lang.NullPointerException</exception-type>

<location>/null.jsp</location>

</error-page>

If a file resource is not found, the server will report a 404 error, and the above configuration would call \webapps\root\notfilefound.jsp.

If a JSP file is executed that produces nullpointexception, it is called \webapps\root\null.jsp

2, Session timeout settings set the session expiration time, the unit is minutes;

<session-config>

</session-timeout>30</session-timeout>

</session-config>

  • Management
    1. User Configuration
    Before specific Tomcat management, add a user to Tomcat so that the user has permission to manage.
    Open the Conf directory under theTomcat-users.xmlFile, add the following line in the appropriate location:
    <user name= "user" password= "user" roles= "Standard,manager"/>
    Then restart Tomcat, enter http://localhost:8080/manager/in the browser, the dialog will pop up, enter the user name and password above.

    2. Application List
    Enter Http://localhost:8080/manager/list in the browser and the browser will display the following information:
    ok-listed applications for virtual host localhost
    /ex:running:1
    /examples:running:1
    /webdav:running:0
    /tomcat-docs:running:0
    /manager:running:0
    /:running:0
    The information shown above is: the path of the application, the current state, the number of sessions connected to the program

    3. Reload the application
    Enter Http://localhost:8080/manager/reload?path=/examples in the browser and the browser appears as follows:
    ok-reloaded Application at Context Path/examples This means that the example application is loaded successfully, and if we set the Server.xml property of the reloadable context element to true, then no It is necessary to reload the application this way because Tomcat is automatically loaded.

    4. Display session Information
    Enter Http://localhost:8080/manager/sessions?path=/examples in the browser and the browser appears as follows:
    Ok-session information for application at Context path/examples Default maximum Session inactiven interval


This article is from the "Henry" blog, please be sure to keep this source http://dihaifeng.blog.51cto.com/8814208/1697407

A detailed description of Tomcat files

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.