Tomcat 4's default connector

1、连接器简介

A Tomcat connector is an independent module that can be plugged into a servlet container. There are already many connectors in existence. Examples include
Coyote, mod_jk, mod_jk2, and mod_webapp. A Tomcat connector must meet the following requirements:
1. It must implement the org.apache.catalina.Connector interface.
2. It must create request objects whose class implements the org.apache.catalina.Request interface.
3. It must create response objects whose class implements the org.apache.catalina.Response interface.

2、连接器用途

It waits for incoming HTTP requests, creates request and response objects, then passes the request and response objects to the container. A connector passes the
request and response objects to the container by calling the org.apache.catalina.Container interface's invoke method, which has the following signature.
   

                 public void invoke(org.apache.catalina.Request request,org.apache.catalina.Response response);

Inside the invoke method, the container loads the servlet class, call its service method, manage sessions, log error messages, etc.

3、连接器工作流程:

talk is cheap,show the code!

注:run方法中的代码为了表述主要过程,有删减

Tomcat 4's default connector

Tomcat 4's default connector

参考:how tomcat works

转载于:https://my.oschina.net/zjg23/blog/853264