1-components of Tomcat Server
1.1-Server
A Server element represents the entire Catalina servlet container. (Singleton)
1.2-Service
A Service element represents the combination of one or more Connector components that share a single Engine
A Service is a collection composed of one or more ctor s and an Engine that processes customer requests obtained by all Connector S.
1.3-Connector
A Connector listens to customer requests on a specified port, sends the obtained requests to the Engine for processing, obtains responses from the Engine, and returns the customer
TOMCAT has two typical ctor, one directly listening for http requests from browser and the other listening for requests from other webservers.
Coyote Http/1.1 Connector listens for http requests from the client browser at port 8080
Coyote JK2 Connector listens to servlet/jsp proxy requests from other WebServer (Apache) at Port 8009
1.4-Engine
The Engine element represents the entire request processing machinery associated with a participant Service
It has es and processes all requests from one or more Connectors
And returns the completed response to the Connector for ultimate transmission back to the client
Multiple Virtual hosts can be configured in the Engine. Each Virtual Host has a domain name.
When the Engine obtains a request, it matches the request to a Host, and then delivers the request to the Host for processing.
The Engine has a default virtual Host. When the request cannot match any Host, the default Host is used for processing.
1.5-Host
Represents a Virtual Host. Each Virtual Host matches the Domain Name of a network Domain.
You can deploy one or more Web apps (web projects written by US) under each virtual host. Each Web App corresponds to one Context and has a Context path.
When the Host receives a request, it matches the request to a Context, and then sends the request to the Context for processing.
The matching method is "Longest match", so a Context with path = "" will become the default Context of the Host.
All requests that cannot match other Context path names will eventually match the default Context.
1.6-Context
A Context corresponds to a Web Application. A Web Application is composed of one or more servlets (a java web project is eventually composed of multiple Servlets, and jsp is eventually translated into Servlet, of course, there are some static files such as html. If these static files are not taken into account, requests to java web applications will eventually become requests to specific servlets)
When the Context is created, it will be based on the configuration file $ CATALINA_HOME/conf/web. xml (a public web configuration file for all projects. The main configuration is to convert requests to jsp files into servlet requests, and finally load and execute this jsp file into a servlet File, therefore, although jsp will eventually convert the servlet successfully, it does not need to be stored on the web. configure url ing in the xml configuration file) and $ WEBAPP_HOME/WEB-INF/web. load the Servlet class in xml (a separate web configuration file for a single project), and generate a servlet ing table from the project url to the Servlet.
When the Context obtains the request, it searches for the matching Servlet class in its own mapping table.
If yes, this class is executed to obtain the request response and return
2-Tomcat Server structure