Detailed explanation of Server.xml content [Tomcat]
Structural diagram of Tomcat Server
##This file describes how to start Tomcat Server
1 |
|
Element name | Attribute | Explanation |
server | port | Specify a port, which is responsible for listening and closing tomcat request |
shutdown | Specifies the command string sent to the port | |
service | name | Specify the name of the service |
Connector (representing the connection between the client and the service) | port | #Specify the server to create The port number, and listen for requests from the client on this port |
minProcessors | Processors created when the server starts Number of threads requested | |
##maxProcessors | Maximum number of threads that can be created to process requests | |
enableLookups | If true, you can get the actual host name of the remote client by calling request.getRemoteHost() to perform a DNS query. If it is false, DNS query will not be performed, but its ip address will be returned. | |
redirectPort | The specified server is processing The port number to redirect after receiving an SSL transfer request when http request | |
acceptCount | Specify when all can When all the threads used to process requests are used, the number of requests that can be placed in the processing queue. Requests exceeding this number will not be processed | |
connectionTimeout | Specify the number of timeouts (in milliseconds) | |
Engine (indicates request processing in the specified service machine, receives and processes requests from Connector) | defaultHost | Specifies the default host name for processing requests, which is at least the same as The name attribute value of a host element is the same |
Context (indicating a web application, usually a WAR file. For specific information about WAR, see the servlet specification) | docBase | The path of the application or the path where the WAR file is stored |
path | represents the prefix of the URL of this web application, so the requested URL is http://localhost:8080/path/**** | |
reloadable | This attribute is very important. If it is true, tomcat will automatically detect the application's /WEB-INF/lib and changes to the /WEB-INF/classes directory to automatically load new applications. We can change applications without restarting tomcat | |
host (Indicates a virtual host) | name | Specify the host name |
appBase | The application base directory, which is the directory where the application is stored | |
suffix | Specify the suffix of the log file | |
timestamp | If it is true, the time must be added to the log file name, as in the following example: localhost_log.001-10-04.txt | |
Realm (represents the database that stores usernames, passwords and roles) | className | Specifies the class used by Realm Name, this class must implement the org.apache.catalina.Realm interface |
Valve (the function is similar to Logger, and its prefix and suffix attribute explanations are the same as those in Logger ) | className | Specify the class name used by Valve. For example, use the org.apache.catalina.valves.AccessLogValve class to record the application's Access information |
directory | Specify the location where the log file is stored | |
pattern | has two values, the common mode records the remote host name or IP address, user name, date, the string requested in the first line, and the HTTP response Code, number of bytes sent. The combined method records more values than the common method |
注意:一个“Server”自身不是一个“Container”(容器),因此在这里你 不可以定义诸如“Valves”或者“Loggers”子组件 –>
在端口8005处等待关闭命令
如果接受到”SHUTDOWN”字符串则关闭服务器
–>
测试: telnet localhost 8005 输入:SHUTDOWN 结果:关闭tomcat
1 |
|
1>className指定实现org.apache.catalina.Server接口的类.默认值为org.apache.catalina.core.StandardServer 2>port指定Tomcat监听shutdown命令端口.终止服务器运行时,必须在Tomcat服务器所在的机器上发出shutdown命令.该属性是必须的. 3>shutdown指定终止Tomcat服务器运行时,发给Tomcat服务器的shutdown监听端口的字符串.该属性必须设置
注意:一个“Service”自身不是一个容器,因此,在这个级别上你不可定义 诸如“Valves”或“Loggers”子组件。 –>
Service是一组Connector的集合
它们共用一个Engine来处理所有Connector收到的请求
–>
1>className 指定实现org.apahce.catalina.Service接口的类.默认为org.apahce.catalina.core.StandardService 2>name定义Service的名字
1 2 3 |
|
第一个Connector元素定义了一个HTTP Connector,它通过8080端口接收HTTP请求;第二个Connector元素定义了一个JD Connector,它通过8009端口接收由其它服务器转发过来的请求.
1 |
|
1>className指定实现Engine接口的类,默认值为StandardEngine 2>defaultHost指定处理客户的默认主机名,在
在
1 2 |
|
在
1 2 |
|
Tomcat Server处理一个http请求的过程
假设来自客户的请求为:
localhost:8080/wsota/wsota_index.jsp
1) 请求被发送到本机端口8080,被在那里侦听的Coyote HTTP/1.1 Connector获得 2) Connector把该请求交给它所在的Service的Engine来处理,并等待来自Engine的回应 3) Engine获得请求localhost/wsota/wsota_index.jsp,匹配它所拥有的所有虚拟主机Host 4) Engine匹配到名为localhost的Host(即使匹配不到也把请求交给该Host处理,因为该Host被定义为该Engine的默认主机) 5) localhost Host获得请求/wsota/wsota_index.jsp,匹配它所拥有的所有Context 6) Host匹配到路径为/wsota的Context(如果匹配不到就把该请求交给路径名为”"的Context去处理) 7) path=”/wsota”的Context获得请求/wsota_index.jsp,在它的mapping table中寻找对应的servlet Context匹配到URL PATTERN为*.jsp的servlet,对应于JspServlet类 9) 构造HttpServletRequest对象和HttpServletResponse对象,作为参数调用JspServlet的doGet或doPost方法 10)Context把执行完了之后的HttpServletResponse对象返回给Host 11)Host把HttpServletResponse对象返回给Engine 12)Engine把HttpServletResponse对象返回给Connector 13)Connector把HttpServletResponse对象返回给客户browser
The above is the detailed content of Detailed explanation of Server.xml content [Tomcat]. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics





Can XML files be opened with PPT? XML, Extensible Markup Language (Extensible Markup Language), is a universal markup language that is widely used in data exchange and data storage. Compared with HTML, XML is more flexible and can define its own tags and data structures, making the storage and exchange of data more convenient and unified. PPT, or PowerPoint, is a software developed by Microsoft for creating presentations. It provides a comprehensive way of

Using Python to merge and deduplicate XML data XML (eXtensibleMarkupLanguage) is a markup language used to store and transmit data. When processing XML data, sometimes we need to merge multiple XML files into one, or remove duplicate data. This article will introduce how to use Python to implement XML data merging and deduplication, and give corresponding code examples. 1. XML data merging When we have multiple XML files, we need to merge them

Convert XML data in Python to CSV format XML (ExtensibleMarkupLanguage) is an extensible markup language commonly used for data storage and transmission. CSV (CommaSeparatedValues) is a comma-delimited text file format commonly used for data import and export. When processing data, sometimes it is necessary to convert XML data to CSV format for easy analysis and processing. Python is a powerful

Implementing filtering and sorting of XML data using Python Introduction: XML is a commonly used data exchange format that stores data in the form of tags and attributes. When processing XML data, we often need to filter and sort the data. Python provides many useful tools and libraries to process XML data. This article will introduce how to use Python to filter and sort XML data. Reading the XML file Before we begin, we need to read the XML file. Python has many XML processing libraries,

Importing XML data into the database using PHP Introduction: During development, we often need to import external data into the database for further processing and analysis. As a commonly used data exchange format, XML is often used to store and transmit structured data. This article will introduce how to use PHP to import XML data into a database. Step 1: Parse the XML file First, we need to parse the XML file and extract the required data. PHP provides several ways to parse XML, the most commonly used of which is using Simple

Python implements conversion between XML and JSON Introduction: In the daily development process, we often need to convert data between different formats. XML and JSON are common data exchange formats. In Python, we can use various libraries to convert between XML and JSON. This article will introduce several commonly used methods, with code examples. 1. To convert XML to JSON in Python, we can use the xml.etree.ElementTree module

Handling Errors and Exceptions in XML Using Python XML is a commonly used data format used to store and represent structured data. When we use Python to process XML, sometimes we may encounter some errors and exceptions. In this article, I will introduce how to use Python to handle errors and exceptions in XML, and provide some sample code for reference. Use try-except statement to catch XML parsing errors When we use Python to parse XML, sometimes we may encounter some

Python parses special characters and escape sequences in XML XML (eXtensibleMarkupLanguage) is a commonly used data exchange format used to transfer and store data between different systems. When processing XML files, you often encounter situations that contain special characters and escape sequences, which may cause parsing errors or misinterpretation of the data. Therefore, when parsing XML files using Python, we need to understand how to handle these special characters and escape sequences. 1. Special characters and
