假設(shè)來(lái)自客戶的請(qǐng)求為:http://localhost:8080/test/index.jsp 請(qǐng)求被發(fā)送到本機(jī)端口8080,被在那里偵聽(tīng)的Coyote HTTP/1.1 Connector,然后
1、Connector把該請(qǐng)求交給它所在的Service的Engine來(lái)處理,并等待Engine的回應(yīng)
2、Engine獲得請(qǐng)求localhost:8080/test/index.jsp,匹配它所有虛擬主機(jī)Host
3、Engine匹配到名為localhost的Host(即使匹配不到也把請(qǐng)求交給該Host處理,因?yàn)樵揌ost被定義為該Engine的默認(rèn)主機(jī))
4、localhost Host獲得請(qǐng)求/test/index.jsp,匹配它所擁有的所有Context
5、Host匹配到路徑為/test的Context(如果匹配不到就把該請(qǐng)求交給路徑名為""的Context去處理)
6、path="/test"的Context獲得請(qǐng)求/index.jsp,在它的mapping table中尋找對(duì)應(yīng)的servlet
7、Context匹配到URL PATTERN為*.jsp的servlet,對(duì)應(yīng)于JspServlet類,構(gòu)造HttpServletRequest對(duì)象和HttpServletResponse對(duì)象,作為參數(shù)調(diào)用JspServlet的doGet或doPost方法
8、Context把執(zhí)行完了之后的HttpServletResponse對(duì)象返回給Host
9、Host把HttpServletResponse對(duì)象返回給Engine
10、Engine把HttpServletResponse對(duì)象返回給Connector
11、Connector把HttpServletResponse對(duì)象返回給客戶browser