Tomcat Core configuration file Server.xml core element configuration

Source: Internet
Author: User
Tags db2 node server server port tomcat server
Tomcat Core configuration file Server.xml core element configuration


In this article, we do not intend to explain the server.xml in depth. Because for most actual developers, there are few operations to configure Server.xml. However, as
The core configuration file for the Tomcat server, Server.xml is configured with some key points that we need to focus on in our development. For example, the Tomcat server's listening port port= "8080". of this article
The aim is to introduce server.xml as a whole and to server.xml a holistic understanding. In this way, "in" We can configure the Server.xml, "back" we can say that we are
A qualified program of apes.


A basic server.xml usually contains the following elements: Server, Service, Engine, Connector, Host, context. These 6 large elements, usually a server.xml, are provided externally
The simplest configuration of the service, of course, is not necessary for the context element, and some applications do not configure the context element node. In this way, the Server.xml configuration file is also quite simple. Well, we
Take a look at the correlation and configuration instructions for these 6 large elements.


Just look at the theory, inevitably boring, first attach a demo of the recent project Server.xml part of the configuration code:


<?xml version= "1.0" encoding= "UTF-8"?> <server port= "8009" shutdown= "Shutdown" > <!--Comment these Entri Es out to disable JMX Mbeans support used for Administration Web application--> <listener classname= "Org.apac He.catalina.core.AprLifecycleListener "/> <listener classname=" Org.apache.catalina.mbeans.ServerLifecycleListener "/> <listener classname=" Org.apache.catalina.mbeans.GlobalResourcesLifecycleListener "/> <listener classname=" Org.apache.catalina.storeconfig.StoreConfigLifecycleListener "/> <!--Global JNDI Resources--> <globalna Mingresources> <!--Test entry for demonstration purposes--> <environment name= "Simplevalue" Type= "J Ava.lang.Integer "value="/> <!--Editable User database that can also is used by Userdatabaserealm to Authen Ticate users--> <resource auth= "Container" description= "User database" can be updated and Sav Ed "factory=" org.Apache.catalina.users.MemoryUserDatabaseFactory "Name=" Userdatabase "pathname=" Conf/tomcat-users.xml " Type= "Org.apache.catalina.UserDatabase"/> <resource driverclassname= "Com.ibm.db2.jcc.DB2Driver" M Axactive= "4" maxidle= "2" maxwait= "5000" name= "Defaultdatasource" password= "aaa111" type = "Javax.sql.DataSource" url= "jdbc:db2://127.0.0.1:50000/" username= "test"/> </globalnamingresources > <!--Define the Tomcat stand-alone Service--> <service name= "Catalina" > <!--Define a non- SSL http/1.1 Connector on port 8080--> <connector uriencoding= "UTF-8" acceptcount= "CO" 
      nnectiontimeout= "20000" disableuploadtimeout= "true" enablelookups= "false" maxhttpheadersize= "8192" maxsparethreads= "maxthreads=" minsparethreads= "5" port= "8080" redirectport= "8443" /> <!--DefinE an AJP 1.3 Connector on port 8009--> <connector uriencoding= "UTF-8" enablelookups= "false" port= "8008" Protoco L= "ajp/1.3" redirectport= "8443"/> <engine defaulthost= "localhost" name= "Catalina" > <realm Classnam E= "Org.apache.catalina.realm.UserDatabaseRealm" resourcename= "Userdatabase"/>  

One, 6 major elements of the association


With node Server: A server.xml has and only one node <Server></Server>
Service: A server and node can contain multiple service nodes. The service node is the basic unit of Tomcat's external delivery services. A service node can contain multiple connector
node, but only one engine node can be included.
Engine: Handles the received request.
Connector: Receives the request from the client.
Host:host is a child container of engine. A engine can contain one or more host nodes. Each host node represents a virtual host. The host virtual host function is to run Web applications,
Includes loading, starting, and ending Web applications. Each host virtual host corresponds to a network domain name entity.
The Context:context node represents a Web application on the specified virtual host. The context is a child container of host, and a host node can contain one or more context nodes. Some projects of
The context node is not configured in Server.xml because the host node is configured with automatic deployment Autodeploy= "true", as mentioned below.


Two, 6 large elements of the attribute configuration detailed


1, with node server: The most common properties are port and shutdown, the shutdown attribute represents the command to shut down the server, and the Port property represents the port number that the server receives the shutdown directive.
2,service: The most common attribute is name, and the usual configuration is Name= "Catalina".
3,engine: The most common properties are the name and Defaulthost,name properties used for logging and error messages, which are globally unique throughout the server, and the Defaulthost property specifies the default host
Name, when the host name specified by the request to the native does not exist, it is handled using the host specified by Defaulthost. Therefore the value of the defaulthost must be the same as the one under the engine node
The host node has the same Name property value.
4,connector: The most common attributes are four: port, protocol, ConnectionTimeout, Redirectport. The Port property represents the port number of the connection request. The Protocol property represents
The protocol for the connection request. The ConnectionTimeout property indicates the time-out period for the connection request. The Redirectport property indicates that when HTTP is requested when an HTTPS is forced, the redirect to the port number is 8443
of connector.
5,host: The most common attributes are four: name, Unpackwars, AppBase, Autodeploy. The Name property represents the hostname of the virtual host, and note that the name value of one of the host nodes is
The defaulthost value of the engine node is the same. The Unpackwars property indicates whether the war file representing the Web application will be decompressed. A value of true runs the Web application through the extracted file structure.
False to run the Web application directly using the war file. The AppBase property represents the directory where the Web application resides, and the default value is WebApps, which is a relative path that represents Tomcat and
Directory under WebApps folder. The Autodeploy property represents the automatic deployment of a Web application, and if true, tomcat periodically checks for new Web applications and updates while it is running.
6,context: The most common attributes are three: docBase, Path, reloadable. The Docbase property represents the path of the war package for the Web application or the directory in which it is applied, in the automatic deployment farm
Under the scene, Docbase is not in the AppBase directory, you need to specify that if docbase the specified war package or application directory is in AppBase, you do not need to specify Docbase. Because Tomcat will automatically
Scanning the war packages and application directories in the appbase specifies a problem. The path attribute represents the context path that accesses the Web application, and Tomcat chooses the web based on the path and URI of the Web application
Apply processing requests (for example,/projectname/index.html). The Reloadable property indicates whether Tomcat monitors the change of class files in the/web-inf/classes and Web-inf/lib directories at run time
Dynamic, if the value is true, Tomcat reloads the application when the class file changes. Reloadable is set to true in the development environment for debugging purposes, but reloadable settings in a production environment
True affects the performance of the server, so the default value for the Reloadable property is false.


The end of this article, then, there are time to share the details of other non-core elements in the server.xml, details, please refer to the small series of follow-up posts
"Tomcat Core profile Server.xml other non-core element configuration"


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.