Ⅰ, request URL
Ⅱ, container search dd, find servlet-mapping
<?XML version= "1.0" encoding= "Iso-8859-1"?><Web-appxmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"version= "2.4"> <servlet> <Servlet-name>Ch3 Beer</Servlet-name> <Servlet-class>Com.example.web.BeerSelect</Servlet-class> </servlet> <servlet-mapping> <Servlet-name>Ch3 Beer</Servlet-name> <url-pattern>/SelectBeer.do</url-pattern> </servlet-mapping></Web-app>
Ⅲ, find the url-pattrern corresponding to the internal DD Servlet-name
< servlet-mapping > <servlet-name>ch3 beer</servlet-name> < Url-pattern >/selectbeer.do</url-pattern> </ Servlet-mapping>
Ⅳ, using Servlet-name to find the corresponding servlet
<servlet> <servlet-name>ch3 beer</servlet-name> <Servlet-class>Com.example.web.BeerSelect</Servlet-class> </servlet> <servlet-mapping> <Servlet-name>Ch3 Beer</Servlet-name> <Url-pattern>/selectbeer.do</Url-pattern> </servlet-mapping>
Ⅴ, container load class, and initialize servlet (if not initialized yet)
< servlet > < Servlet-name > Ch3 Beer</servlet-name> <servlet-class> com.example.web.beerselect</servlet-class> </servlet>
Ⅵ, container opens a new thread processing and passes the request (the service () method passed to the servlet)
How does the container handle the request?
Ⅶ, the container sends the response back to the customer
The Java Web maps the logical name to the servlet file