One, servlet technology
1. What is a servlet
A custom-built component specification for the extended Web server side (Java applications on the server side). With platform and protocol-independent features, you can generate dynamic Web pages that serve as the middle tier for client requests and server-side responses.
2. Different from CGI
Java servlet is more efficient and resource-saving (CGI exists in the process of client request activation, and the request is unloaded after it is activated by the client's first request, and the servlet is running in the background, waiting to process the next request, each request being just a thread rather than a process. It is only uninstalled when the servlet container is stopped or restarted), easier to implement (CGI development is more difficult, the servlet inherits Java's easy-to-develop features), and has better portability (CGI is not portable).
3. When the servlet is initialized
If Loadonstartup is not set, it is instantiated the first time it is requested (after the servlet is instantiated, Tomcat invokes the Init () method to initialize the object)
Set Loadonstartup in three different situations:
(1) Loadonstartup < 0
In the case of negative numbers, the Web container is not instantiated when it is started, and is instantiated the first time it is requested.
(2) loadonstartup > 0
When the Web container starts, it is instantiated, the order is small to large, and the smaller the positive integer is first instantiated.
(3) Loadonstartup = 0
When the Web container is started, it is instantiated, equivalent to the maximum positive integer, which is initialized at web startup.
4. Links to related posts
When is the https://www.cnblogs.com/disneyland/p/4692339.html servlet instantiated?
52329543
A single-instance understanding of the 45898661 servlet
Java face question