search
HomeBackend DevelopmentXML/RSS TutorialDetailed explanation of Server.xml content [Tomcat]

Structural diagram of Tomcat Server

##This file describes how to start Tomcat Server


<server>  <listener></listener>  <globanamingresources>  </globanamingresources>  <service>  <connector></connector>  <engine>  <logger></logger>  <realm></realm>  <host>  <logger></logger>  <context></context>  </host>  </engine>  </service> </server>
##unpackWARsIf it is true, tomcat will automatically decompress the WAR file, otherwise it will not decompress and run the application directly from the WAR file Logger (representing logs, debugging and error information)classNameSpecifies the class name used by the logger. This class must implement org.apache. catalina.Logger interfaceprefixSpecify the prefix of the log file
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

元素 它代表整个容器,是Tomcat实例的顶层元素.由org.apache.catalina.Server接口来定义.它包含一个元素.并且它不能做为任何元素的子元素.

注意:一个“Server”自身不是一个“Container”(容器),因此在这里你 不可以定义诸如“Valves”或者“Loggers”子组件 –>

在端口8005处等待关闭命令 如果接受到”SHUTDOWN”字符串则关闭服务器 –>

测试: telnet localhost 8005 输入:SHUTDOWN 结果:关闭tomcat


<server></server>

1>className指定实现org.apache.catalina.Server接口的类.默认值为org.apache.catalina.core.StandardServer 2>port指定Tomcat监听shutdown命令端口.终止服务器运行时,必须在Tomcat服务器所在的机器上发出shutdown命令.该属性是必须的. 3>shutdown指定终止Tomcat服务器运行时,发给Tomcat服务器的shutdown监听端口的字符串.该属性必须设置

元素 该元素由org.apache.catalina.Service接口定义,它包含一个元素,以及一个或多个,这些Connector元素共享用同一个Engine元素

注意:一个“Service”自身不是一个容器,因此,在这个级别上你不可定义 诸如“Valves”或“Loggers”子组件。 –>

Service是一组Connector的集合 它们共用一个Engine来处理所有Connector收到的请求 –>

第一个处理所有直接由Tomcat服务器接收的web客户请求. 第二个处理所有由Apahce服务器转发过来的Web客户请求 .

1>className 指定实现org.apahce.catalina.Service接口的类.默认为org.apahce.catalina.core.StandardService 2>name定义Service的名字

元素 由Connector接口定义.元素代表与客户程序实际交互的给件,它负责接收客户请求,以及向客户返回响应结果.


<connector></connector><connection></connection>

第一个Connector元素定义了一个HTTP Connector,它通过8080端口接收HTTP请求;第二个Connector元素定义了一个JD Connector,它通过8009端口接收由其它服务器转发过来的请求.

元素 每个Service元素只能有一个Engine元素.处理在同一个中所有元素接收到的客户请求.由org.apahce.catalina.Engine接口定义.


<engine></engine>

1>className指定实现Engine接口的类,默认值为StandardEngine 2>defaultHost指定处理客户的默认主机名,在中的子元素中必须定义这一主机 3>name定义Engine的名字

可以包含如下元素, , ,

元素 它由Host接口定义.一个Engine元素可以包含多个元素.每个的元素定义了一个虚拟主机.它包含了一个或多个Web应用.


的相对目录.如果没有此项,默认 为<catalina_home>/webapps. 它将匹配请求和自己的Context的路径,并把请求转交给对应的Context来处 理 autoDeploy:如果此项设为true,表示Tomcat服务处于运行状态时,能够监测appBase下的文件,如果有新有web应用加入进来,会自运发布这个WEB应用 unpackWARs:如果此项设置为true,表示把WEB应用的WAR文件先展开为开放目录结构后再运行.如果设为false将直接运行为WAR文件 alias:指定主机别名,可以指定多个别名 deployOnStartup:如果此项设为true,表示Tomcat服务器启动时会自动发布appBase目录下所有的Web应用.如果Web应用 中的server.xml没有相应的<context>元素,将采用Tomcat默认的Context –> 
<host></host></context></catalina_home>

元素中可以包含如下子元素 , , , 元素 它由Context接口定义.是使用最频繁的元素.每个可以包含多个元素.每个web应用有唯一 的一个相对应的Context代表web应用自身.servlet容器为第一个web应用创建一个


 
 <context></context>

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
RSS in XML: Unveiling the Core of Content SyndicationRSS in XML: Unveiling the Core of Content SyndicationApr 22, 2025 am 12:08 AM

The implementation of RSS in XML is to organize content through a structured XML format. 1) RSS uses XML as the data exchange format, including elements such as channel information and project list. 2) When generating RSS files, content must be organized according to specifications and published to the server for subscription. 3) RSS files can be subscribed through a reader or plug-in to automatically update the content.

Beyond the Basics: Advanced RSS Document FeaturesBeyond the Basics: Advanced RSS Document FeaturesApr 21, 2025 am 12:03 AM

Advanced features of RSS include content namespaces, extension modules, and conditional subscriptions. 1) Content namespace extends RSS functionality, 2) Extended modules such as DublinCore or iTunes to add metadata, 3) Conditional subscription filters entries based on specific conditions. These functions are implemented by adding XML elements and attributes to improve information acquisition efficiency.

The XML Backbone: How RSS Feeds are StructuredThe XML Backbone: How RSS Feeds are StructuredApr 20, 2025 am 12:02 AM

RSSfeedsuseXMLtostructurecontentupdates.1)XMLprovidesahierarchicalstructurefordata.2)Theelementdefinesthefeed'sidentityandcontainselements.3)elementsrepresentindividualcontentpieces.4)RSSisextensible,allowingcustomelements.5)Bestpracticesincludeusing

RSS & XML: Understanding the Dynamic Duo of Web ContentRSS & XML: Understanding the Dynamic Duo of Web ContentApr 19, 2025 am 12:03 AM

RSS and XML are tools for web content management. RSS is used to publish and subscribe to content, and XML is used to store and transfer data. They work with content publishing, subscriptions, and update push. Examples of usage include RSS publishing blog posts and XML storing book information.

RSS Documents: The Foundation of Web SyndicationRSS Documents: The Foundation of Web SyndicationApr 18, 2025 am 12:04 AM

RSS documents are XML-based structured files used to publish and subscribe to frequently updated content. Its main functions include: 1) automated content updates, 2) content aggregation, and 3) improving browsing efficiency. Through RSSfeed, users can subscribe and get the latest information from different sources in a timely manner.

Decoding RSS: The XML Structure of Content FeedsDecoding RSS: The XML Structure of Content FeedsApr 17, 2025 am 12:09 AM

The XML structure of RSS includes: 1. XML declaration and RSS version, 2. Channel (Channel), 3. Item. These parts form the basis of RSS files, allowing users to obtain and process content information by parsing XML data.

How to Parse and Utilize XML-Based RSS FeedsHow to Parse and Utilize XML-Based RSS FeedsApr 16, 2025 am 12:05 AM

RSSfeedsuseXMLtosyndicatecontent;parsingtheminvolvesloadingXML,navigatingitsstructure,andextractingdata.Applicationsincludebuildingnewsaggregatorsandtrackingpodcastepisodes.

RSS Documents: How They Deliver Your Favorite ContentRSS Documents: How They Deliver Your Favorite ContentApr 15, 2025 am 12:01 AM

RSS documents work by publishing content updates through XML files, and users subscribe and receive notifications through RSS readers. 1. Content publisher creates and updates RSS documents. 2. The RSS reader regularly accesses and parses XML files. 3. Users browse and read updated content. Example of usage: Subscribe to TechCrunch's RSS feed, just copy the link to the RSS reader.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.