Tomcat's response and overall architecture

Introduction to Tomcat

 web服务器软件:接收用户的请求,处理请求做出响应。可以部署web项目,让用户通过浏览器来访问这些项目。

Tomcat is a lightweight, free and open source web application server, which is generally suitable for small and medium-sized systems and occasions where there are not many concurrent users. It is the first choice for developing and debugging JSP.

Tomcat overall architecture

HTTP protocol

Mainly stipulates the communication format between the client and the server.

Tomcat response process

That is: HTTP server request processing and the Servlet container workflow are
decoupled. After receiving the request, the HTTP server will not directly call the service class (java code), but will send the request directly to the Servlet container, and the Servlet container will then decide which service class to call . The HTTP server encapsulates the client's request information in a ServletRequest object and sends it to the Servlet container. The Servlet container finds the corresponding Servlet after receiving the request. If the Servlet has not been loaded, it creates the Servlet and calls the init method to initialize. Call the service method to process the request, and finally return the ServletResponse object to the HTTP server, and the HTTP server will send the response to the client.
Tomcat response process

Implementation of two core functions of Tomcat

Two core functions

  1. Process Socket (port number) connection, responsible for the conversion of network byte stream and Request and Response objects.
  2. Load and manage Servlet, and specifically handle Request requests.
    Insert picture description here

Two core components

 1.连接器(Connector):负责对外交流         

Insert picture description here

  2.容器(Container):负责内部处理

Insert picture description here

Coyote and Catelina

  1. Coyote is the name of Tomcat's connector framework, responsible for the analysis of specific protocols and related operations of IO.
  2. Catalina is a Servlet container implementation, responsible for specific logic execution, and is the core of Tomcat.

Note:

  1. One container can be docked with multiple connectors
  2. Only the combination of Coyote and Catalina can provide external services. In the Tomcat architecture, a Service can provide external services alone. A Service contains at least one Coyote and Catalina, and there are multiple Services under the Server.

Catalina components:
Catalina components

Tomcat's module layering

Layering reflected in the source code

Insert picture description here

Abstraction layering

Insert picture description here

Refer to the analysis of the core principles of Tomcat in the java advanced tutorial at station b (https://www.bilibili.com/video/BV1dJ411N7Um?p=10)

Guess you like

Origin blog.csdn.net/weixin_46064382/article/details/106170942