The role of files in the Tomcat conf directory

Source: Internet
Author: User

This article takes apache-tomcat-6.0.26 as the quasi-introduction

1. Web. xml:

Default (Welcome) file Settings

Configuration includes: Primarily configuration servlet, including initialization parameters, setting session, etc.

<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

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

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>



2. Tomcat-users.xml:

<role rolename= "Tomcat"/>
<role rolename= "Role1"/>
<user username= "Tomcat" password= "Tomcat" roles= "Tomcat"/>
<user username= "Both" password= "Tomcat" roles= "Tomcat,role1"/>
<user username= "Role1" password= "Tomcat" roles= "Role1"/>

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


3. Server.xml: (for Server (tomcat) configuration)

<server port= "9005" shutdown= "Shutdown" >

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
Service
1. Name Specifies the service
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 on this port
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, Redirectport specifies that the server is processing an HTTP request when it receives an SSL transfer request after the redirected
Port number
5. Acceptcount specifies that when the number of threads that can be used for processing requests is used, it can be put into processing
Number of requests in the queue, requests that exceed this number will not be processed
6. ConnectionTimeout specifies the number of times to time out (in milliseconds)
Engine (representing the request processor in the specified service, receiving and processing requests from connector):
1. DEFAULTHOST Specifies the default host name for the processing request, at least with the name of one of the host elements
Property values are the same
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 the application's
/web-inf/lib and/web-inf/classes directory changes, automatic loading of new applications, we can
To change the application without restarting Tomcat (i.e. hot deployment)
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 extract the war file, otherwise without pressure, directly
Run the application 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, as follows
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 used by valve, e.g. with org.apache.catalina.valves.AccessLogValve
Class can record access information for an application
Directory (Specify the location where the log file is stored):
1, pattern has two values, common way to record the remote host name or IP address, user name, date, the first line
The requested string, the HTTP response code, and the number of bytes sent. Combined way than common way
The value of the record is more


4. Context.xml: (for project configuration)


2. After Tomcat 5.5:


Configuration in Server.xml is not recommended, but it is configured independently in the/conf/context.xml. Since Server.xml is a resource that cannot be reloaded dynamically, once the server has been started, to modify the file, you will have to restart the server to reload. The context.xml file does not, and the Tomcat server scans the file periodically. Once the file is found to be modified (the timestamp changes), the file is automatically reloaded without restarting the server.


<context path= "/kaka" docbase= "Kaka" debug= "0" reloadbale= "true" privileged= "true" >


<WatchedResource>WEB-INF/web.xml</WatchedResource>


<WatchedResource>WEB-INF/kaka.xml</WatchedResource> Monitor resource file if Web. xml | | Kaka.xml changed, then automatically reload and change the application.


<resource name= "Jdbc/testsiteds" indicates the specified Jndi name
Auth= "Container" means authentication method, generally Container
Type= "Javax.sql.DataSource"
Maxactive= the maximum number of connections supported by the "100" Connection pool
maxidle= "30" connection pool can have up to maxidle of free connections
maxwait= "10000" connection pool when the connection is exhausted, new request wait time, milliseconds
Username= "Root" indicates the database user name
password= "Root" indicates the password of the database user
Driverclassname= "com.mysql.jdbc.Driver" means JDBC Driver
Url= "Jdbc:mysql://localhost:3306/testsite"/> means database URL address

</Context>

Attached: context.xml three range of functions:

1. Tomcat Server level:
Configure in/conf/context.xml
2. Host Level:
Add Context.xml in/conf/catalina/${hostname}, then configure
3. Web App Level:
Add ${webappname}.xml in/conf/catalina/${hostname}, then configure

Note: The above content has on-line information and my conclusion,

The role of files in the Tomcat conf directory

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.