JSP is the essence of the servlet, the developer's JSP file will be compiled by the Web container into the corresponding servlet, when the servlet is running in the container, the creation and destruction of its instance is not determined by the programmer, but by the Web container control.
There are two opportunities to create a servlet:
1. When a client requests a servlet for the first time, the system creates an instance of the servlet, most of which are the servlet.
2.WEB application starts to create a servlet instance immediately, that is, Load-start-servlet.
Each servlet runs in accordance with the following life cycle
1. Create a servlet instance
The 2.Web container invokes the servlet's Init method and initializes the servlet
3.Servlet initialization will always exist in the container to respond to client requests. If the client sends a GET request, the container invokes the Doget method to process and respond to the request, and if the client sends a POST request, the container invokes the Dopost method in the servlet to process and respond to the request. Or use a unified service () method to handle responding to customer requests.
4.WEb container when deciding to destroy a servlet, first invoke the servlet's Destroy () method, which usually destroys the servlet when the Web application is closed.