Servlet life cycle
-
When a servlet is requested for the first time, the servlet is instantiated, and the instance resides in memory, in response to subsequent requests! (if Load-on-startup is added to the configuration of the servlet, the servlet is instantiated directly when the server is started)
-
After the servlet is instantiated, the init () method is called immediately, and the method is called only once between the entire life cycle.
-
The service () method is invoked each time the servlet is requested (callback Doget,dopost)
-
When the Web application is about to be uninstalled, the Destroy method is called, which executes only once between the entire servlet life cycle
Filter life cycle
-
When the server is started, the filter is instantiated directly, and the instance will remain in memory to intercept subsequent requests!
-
The Init method is called immediately after the filter is instantiated
-
The Dofilter method is executed each time the filter intercepts the request.
-
When the Web application is about to be uninstalled, the Destroy method is called, which executes only once between the entire filter life cycle
Interceptor (Interceptor) life cycle
-
When the server is started, the interceptor is instantiated directly, and the instance resides in memory to intercept subsequent requests!
-
The Init method is called immediately after the interceptor is instantiated
-
The Intercept method is executed each time the interceptor intercepts the request.
-
When the Web application is about to be uninstalled, the Destroy method is called, which executes only once between the entire interceptor life cycle
A variety of life cycles in Java