从上图可以清楚的体现了servlet的生命周期,处理过程说明:
1. A client browser requests a resource on the web server.
2. The web server checks the request. If it is for a static resource, the web server
locates the static resource and transmits it to the client. Skip to step 6.
The Tomcat container, when deployed in standalone mode,
can play the roles of both the web server and a servlet
container and can serve up both static and dynamic resources.
3. If it is for a dynamic resource that is being served up by a servlet container,
the web server delegates to the servlet container instead, which must locate
the servlet that will process this request. It uses the request URI as well as the
mappings declared in the deployment descriptor to locate the appropriate
servlet. If the servlet is already loaded and initialized, then skip to step 4.
Otherwise, the appropriate servlet class is located, loaded, and
instantiated. The servlet's init() method is then called, to give it a
chance to initialize itself.
4. It then invokes the service() method of the servlet to generate the
appropriate response.
5. The response is generated.
6. The web server returns the completed response to the client browser.
7. The client browser renders the rendered response.
阅读(683) | 评论(0) | 转发(0) |