學(xué)習(xí)JSP有一段時(shí)間了,對(duì)
Tomcat
Server環(huán)境配置也有了一些心得,陸續(xù)會(huì)把
Tomcat
Server的幾篇文章拿出來(lái)跟大家分享一下,本篇先先說(shuō)一下
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所獲得的客戶請(qǐng)求
1.3 - Connector
一個(gè)Connector將在某個(gè)指定端口上偵聽(tīng)客戶請(qǐng)求,并將獲得的請(qǐng)求交給Engine來(lái)處理,從Engine處獲得回應(yīng)并返回客戶
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)自客戶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和$ WEB APP_HOME/ WEB -INF/web.xml載入Servlet類
當(dāng)Context獲得請(qǐng)求時(shí),將在自己的映射表(mapping table)中尋找相匹配的Servlet類
如果找到,則執(zhí)行該類,獲得請(qǐng)求的回應(yīng),并返回?
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所獲得的客戶請(qǐng)求
1.3 - Connector
一個(gè)Connector將在某個(gè)指定端口上偵聽(tīng)客戶請(qǐng)求,并將獲得的請(qǐng)求交給Engine來(lái)處理,從Engine處獲得回應(yīng)并返回客戶
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)自客戶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和$ WEB APP_HOME/ WEB -INF/web.xml載入Servlet類
當(dāng)Context獲得請(qǐng)求時(shí),將在自己的映射表(mapping table)中尋找相匹配的Servlet類
如果找到,則執(zhí)行該類,獲得請(qǐng)求的回應(yīng),并返回?
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
