Tomcat的核心是Connector和Container,被Service包裝,所有的Service由最外層的Server統(tǒng)一管理
Server->service1(多個service)->Connectors(每個service對應(yīng)多個connector)->Engine(處理引擎)->Host(多個主機資源)->Context(多個虛擬目錄)
組織結(jié)構(gòu)描述
Server
Service
Contector
Engine
Host
Context
樣本描述
http://localhost:8080/wsota/wsota_index.jsp
發(fā)送請求到8080端口,被Connector監(jiān)聽獲取
Connector完成http協(xié)議解析,把請求交給Service的Engine處理,等待Engine的返回
Engine獲取localhost:8080/wsota/wsota_index.jsp,進行虛擬主機的匹配,找到localhost的Host
Engine獲取wsota/wsota_index.jsp,進行虛擬目錄的匹配,找到Host的wsota對應(yīng)的Context
path為wsota的Context對象獲取wsota_index.jsp,開始找到這個url的映射的servlet,主要看.jsp后綴
開始構(gòu)造httpServletRequest和HttpServletResponse對象,作為參數(shù)傳遞給Servlet的doGet和doPost方法
Context把處理之后的HttpServletResponse對象返回給Host
Host對象把HttpServletResponse對象返回給Engine
Engine對象把HttpServletResponse對象返回給Connector
Connector對象把HttpServletResponse返回給瀏覽器
Connector關(guān)閉Socket