国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

Tomcat啟動(dòng)分析server.xml

2019-11-17 03:57:06
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
 - 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
Service是這樣一個(gè)集合:它由一個(gè)或者多個(gè)Connector組成,以及一個(gè)Engine,負(fù)責(zé)處理所有Connector所獲得的客戶(hù)請(qǐng)求

1.3 - Connector

一個(gè)Connector將在某個(gè)指定端口上偵聽(tīng)客戶(hù)請(qǐng)求,并將獲得的請(qǐng)求交給Engine來(lái)處理,從Engine處獲得回應(yīng)并返回客戶(hù)
TOMCAT有兩個(gè)典型的Connector,一個(gè)直接偵聽(tīng)來(lái)自browser的http請(qǐng)求,一個(gè)偵聽(tīng)來(lái)自其它WebServer的請(qǐng)求
Coyote Http/1.1 Connector 在端口8080處偵聽(tīng)來(lái)自客戶(hù)browser的http請(qǐng)求
Coyote JK2 Connector 在端口8009處偵聽(tīng)來(lái)自其它WebServer(Apache)的servlet/jsp代理請(qǐng)求

1.4 - Engine

The Engine element represents the entire request processing machinery associated with a particular Service
It receives and processes all requests from one or more Connectors
and returns the completed response to the Connector for ultimate transmission back to the client
Engine下可以配置多個(gè)虛擬主機(jī)Virtual Host,每個(gè)虛擬主機(jī)都有一個(gè)域名
當(dāng)Engine獲得一個(gè)請(qǐng)求時(shí),它把該請(qǐng)求匹配到某個(gè)Host上,然后把該請(qǐng)求交給該Host來(lái)處理
Engine有一個(gè)默認(rèn)虛擬主機(jī),當(dāng)請(qǐng)求無(wú)法匹配到任何一個(gè)Host上的時(shí)候,將交給該默認(rèn)Host來(lái)處理

1.5 - Host

代表一個(gè)Virtual Host,虛擬主機(jī),每個(gè)虛擬主機(jī)和某個(gè)網(wǎng)絡(luò)域名Domain Name相匹配
每個(gè)虛擬主機(jī)下都可以部署(deploy)一個(gè)或者多個(gè)Web App,每個(gè)Web App對(duì)應(yīng)于一個(gè)Context,有一個(gè)Context path
當(dāng)Host獲得一個(gè)請(qǐng)求時(shí),將把該請(qǐng)求匹配到某個(gè)Context上,然后把該請(qǐng)求交給該Context來(lái)處理
匹配的方法是“最長(zhǎng)匹配”,所以一個(gè)path==""的Context將成為該Host的默認(rèn)Context
所有無(wú)法和其它Context的路徑名匹配的請(qǐng)求都將最終和該默認(rèn)Context匹配

1.6 - Context

一個(gè)Context對(duì)應(yīng)于一個(gè)Web application,一個(gè)Web Application由一個(gè)或者多個(gè)Servlet組成
Context在創(chuàng)建的時(shí)候?qū)⒏鶕?jù)配置文件$CATALINA_HOME/conf/web.xml和$WEBAPP_HOME/WEB-INF/web.xml載入Servlet類(lèi)
當(dāng)Context獲得請(qǐng)求時(shí),將在自己的映射表(mapping table)中尋找相匹配的Servlet類(lèi)
如果找到,則執(zhí)行該類(lèi),獲得請(qǐng)求的回應(yīng),并返回

2 - Tomcat Server的結(jié)構(gòu)圖
3 - 配置文件$CATALINA_HOME/conf/server.xml的說(shuō)明
該文件描述了如何啟動(dòng)Tomcat Server



  

  
  

  

  
    ... ... ... ...
  

  

  

    

                   port="8080"
               minProcessors="5" maxProcessors="75" acceptCount="100"
               enableLookups="true"
               redirectPort="8443"
               debug="0"
               connectionTimeout="20000"
               useURIValidationHack="false"
               disableUploadTimeout="true" />

    

    

      

      

      

      

      

      

        

        

        

        

        

        
      
    

  


4 - Context的部署配置文件web.xml的說(shuō)明
一個(gè)Context對(duì)應(yīng)于一個(gè)Web App,每個(gè)Web App是由一個(gè)或者多個(gè)servlet組成的
當(dāng)一個(gè)Web App被初始化的時(shí)候,它將用自己的ClassLoader對(duì)象載入“部署配置文件web.xml”中定義的每個(gè)servlet類(lèi)
它首先載入在$CATALINA_HOME/conf/web.xml中部署的servlet類(lèi)
然后載入在自己的Web App根目錄下的WEB-INF/web.xml中部署的servlet類(lèi)
web.xml文件有兩部分:servlet類(lèi)定義和servlet映射定義
每個(gè)被載入的servlet類(lèi)都有一個(gè)名字,且被填入該Context的映射表(mapping table)中,和某種URL PATTERN對(duì)應(yīng)
當(dāng)該Context獲得請(qǐng)求時(shí),將查詢(xún)mapping table,找到被請(qǐng)求的servlet,并執(zhí)行以獲得請(qǐng)求回應(yīng)

分析一下所有的Context共享的web.xml文件,在其中定義的servlet被所有的Web App載入


  

  
  
  

  

    
        default
        
          org.apache.catalina.servlets.DefaultServlet
        
        
            debug
            0
        
        
            listings
            true
        
        1
    

  

    
        invoker
        
          org.apache.catalina.servlets.InvokerServlet
        
        
            debug
            0
        
        2
    

  

    
        jsp
        org.apache.jasper.servlet.JspServlet
        
            logVerbosityLevel
            WARNING
        
        3
    

  
  
  

    
        default
        /
    

    
        invoker
        /servlet/*
    

    
        jsp
        *.jsp
    

  
  
  

    ... ... ... ...


5 - Tomcat Server處理一個(gè)http請(qǐng)求的過(guò)程
假設(shè)來(lái)自客戶(hù)的請(qǐng)求為:
http://localhost:8080/wsota/wsota_index.jsp

1) 請(qǐng)求被發(fā)送到本機(jī)端口8080,被在那里偵聽(tīng)的Coyote HTTP/1.1 Connector獲得

2) Connector把該請(qǐng)求交給它所在的Service的Engine來(lái)處理,并等待來(lái)自Engine的回應(yīng)

3) Engine獲得請(qǐng)求localhost/wsota/wsota_index.jsp,匹配它所擁有的所有虛擬主機(jī)Host

4) Engine匹配到名為localhost的Host(即使匹配不到也把請(qǐng)求交給該Host處理,因?yàn)樵揌ost被定義為該Engine的默認(rèn)主機(jī))

5) localhost Host獲得請(qǐng)求/wsota/wsota_index.jsp,匹配它所擁有的所有Context

6) Host匹配到路徑為/wsota的Context(如果匹配不到就把該請(qǐng)求交給路徑名為""的Context去處理)

7) path="/wsota"的Context獲得請(qǐng)求/wsota_index.jsp,在它的mapping table中尋找對(duì)應(yīng)的servlet

8) Context匹配到URL PATTERN為*.jsp的servlet,對(duì)應(yīng)于JspServlet類(lèi)

9) 構(gòu)造HttpServletRequest對(duì)象和HttpServletResponse對(duì)象,作為參數(shù)調(diào)用JspServlet的doGet或doPost方法

10)Context把執(zhí)行完了之后的HttpServletResponse對(duì)象返回給Host

11)Host把HttpServletResponse對(duì)象返回給Engine

12)Engine把HttpServletResponse對(duì)象返回給Connector

13)Connector把HttpServletResponse對(duì)象返回給客戶(hù)browser

本文出處:http://lib.360doc.com/05/1116/10/2689_31126.shtml



本文來(lái)自CSDN博客,轉(zhuǎn)載請(qǐng)標(biāo)明出處:http://blog.csdn.net/cyq1984/archive/2009/12/17/5026764.aspx
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 太仆寺旗| 孟州市| 凭祥市| 长寿区| 日土县| 慈利县| 隆昌县| 宾川县| 获嘉县| 台湾省| 清镇市| 环江| 蒙阴县| 从江县| 修文县| 营山县| 武胜县| 汶川县| 昌宁县| 高州市| 扶绥县| 巴彦淖尔市| 鄂托克前旗| 梁山县| 长兴县| 靖江市| 科尔| 田林县| 图木舒克市| 黎平县| 贵南县| 柳河县| 饶河县| 景德镇市| 精河县| 祥云县| 云梦县| 尚志市| 株洲市| 兴安盟| 巫山县|