The server. xml file and context. xml file under Tomcat

Source: Internet
Author: User

<Server> element
It represents the entire container and is the top-level element of the Tomcat instance. by Org. apache. catalina. server interface to define. it contains a <service> element. it cannot be a child element of any element.

<Server port = "8005" shutdown = "shutdown" DEBUG = "0">

1> classname specifies the class that implements the org. Apache. Catalina. server interface. The default value is org. Apache. Catalina. Core. standardserver.
2> port: Specifies the port for Tomcat to listen to the shutdown command. When the server is terminated, the shutdown command must be issued on the machine where the Tomcat server is located. This attribute is required.
3> shutdown specifies the string of the shutdown listening port sent to the Tomcat server when the Tomcat server is terminated. This attribute must be set

<Service> element
This element is defined by the org. Apache. Catalina. service interface. It contains one <engine> element and one or more <connector> elements that share the same engine element.

<Service name = "Catalina">
<Service name = "Apache">
The first <service> process all Web client requests directly received by the Tomcat server.
The second <service> process all Web client requests forwarded by the apahce Server

1> classname specifies the class that implements the org. apahce. Catalina. service interface. The default value is org. apahce. Catalina. Core. standardservice.
2> name defines the service name

<Engine> element
Each service element can have only one engine element. The element processes customer requests received by all <connector> elements in the same <service>. This is defined by the org. apahce. Catalina. Engine interface.

<Engine name = "Catalina" defaulthost = "localhost" DEBUG = "0">

1> classname specifies the class that implements the engine interface. The default value is standardengine.
2> defaulthost specifies the default host name for processing the customer. This host must be defined in the 3> name defines the engine name

<Engine> can contain the following elements: <logger>, <realm>, <value>, and

<Host> element
It is defined by the host interface. An engine element can contain multiple

<Host name = "localhost" DEBUG = "0" appbase = "webapps" unpackwars = "true" autodeploy = "true">

1> classname specifies the class that implements the host interface. The default value is standardhost.
2> appbase: Specifies the virtual host directory. You can specify an absolute directory or a relative directory relative to <catalina_home>. If this option is not available, the default value is <catalina_home>/webapps.
3> autodeploy if this option is set to true, it indicates that when the Tomcat service is running, files under appbase can be monitored. If a new Web application is added, the Web application will be released automatically.
4> unpackwars: If this option is set to true, the war file of the Web application is expanded to an open directory structure before running. If this option is set to false, the war file is directly run.
5> alias specifies the host alias. You can specify multiple aliases.
6> deployonstartup if this option is set to true, all web applications under the appbase directory will be automatically published when the Tomcat server is started. if the server. XML does not have the corresponding <context> element. The default context of Tomcat is used.
7> name defines the name of the VM.

The <Logger>, <realm>, <value>, <context>

<Context> element
It is defined by the context interface. is the most frequently used element. each <context element represents a single web application running on the VM. one A corresponding context represents the web application itself. The servlet container creates
Servletcontext object.

<Context Path = "/sample" docbase = "sample" DEBUG = "0" reloadbale = "true">

1> classname specifies the class that implements the context. The default value is the standardcontext class.
2> path specifies the URL entry for accessing the web application. Note/myweb instead of myweb.
3> reloadable if this property is set to true, the Tomcat server will monitor the change in the class file in the WEB-INF/classes and web-INF/lib directory while running. if a class file is updated, the server automatically reloads the web application.
3> cookies specify whether the session is supported through cookies. The default value is true.
4> usenaming specifies whether JNDI is supported. The default value is true.

The <context> element can contain the following elements:
<Logger>, <realm>, <resource>, <resourceparams>

Connector Element
Defined by connector interface. <connector> elements represent customersProgramThe actual interaction sender, which is responsible for receiving customer requests and returning response results to the customer.

<Connector Port = "8080" maxthread = "50" minsparethreads = "25" maxsparethread = "75" enablelookups = "false" redirectport = "8443" acceptcount = "100" DEBUG =" 0 "connectiontimeout =" 20000 "disableuploadtimeout =" true "/>

<Connection Port = "8009" enablelookups = "false" redirectport = "8443" DEBUG = "0" protocol = "AJP/1.3"/>
The first connector element defines an HTTP connector, which receives HTTP requests through port 8080, and the second connector element defines a JD connector, it receives requests forwarded by other servers through port 8009.

Connector element sharing attributes
1> classname specifies the class to implement the connector Interface
2> If enablelookups is set to true, domain name resolution is supported. You can resolve the IP address to the host name. In the web application, call request. getremotehost to return the client host name. The default value is true.
3> redirectport specifies the forwarding port. If the current port only supports non-SSL requests, the customer request will be forwarded to the SSL redirectport in the field requiring secure communication.
Attribute of the httpconnector Element
1> classname: class for implementing ctor
2> port: Set the TCP/IP Port. The default value is 8080. If you change 8080 to 80, you only need to enter
Http: // localhost Yes
because the default TCP/IP Port is 80
3> address: if the server has more than two IP addresses, you can set the IP address of the port listening. by default, the port listens to all IP addresses on the server
4> buffersize sets the cache size of the input stream created by the port. the default value is 2048 bytes.
5> Protocol sets the HTTP protocol. The default value is HTTP/1.1.
6> maxthreads sets the maximum number of threads on the listening port, this value also determines the maximum number of client requests that the server can respond to at the same time. the default value is 200
7> acceptcount. It is set to the maximum number of customer requests in the listening port queue. The default value is 10. if the queue is full, the customer must wait.
8> connectiontimeout defines the timeout time for establishing a customer connection. if the value is-1, the time for establishing a client connection is not limited.
jkconnector attributes
1> classname implements connector's Class
2> port setting AJP port number
3> protocol must be set to AJP/1.3
note: * **********************
tomcat5.0 and tomcat5.5 servers. the XML file configuration is different. Because the context configuration of tomcat5.5 is extracted from the server. xml file and configured independently, you must use the resourcelink element to specify it. The following is a configuration Demo:

in this example, the project application name is Stu, that is, the container name. 1. Configure the STU/WEB-INF/Web. xml file to add the following Code :

database: Student JNDI JDBC/STU javax. SQL. datasource container retriable


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.