1. The ServletConfig interface is used to describe the relevant configuration information of the Servlet itself. The ServletContext interface is used to describe information related to the application (a Context configuration in server.xml, that is, a virtual directory).
2.Servlet configuration initialization parameters, for example:
Copy the code code as follows:
<servlet>
<servlet-name>XXX</servlet-name>
<servlet-class>Xxx</servlet-class>
<init-param>
<param-name>yyy</param-name>
<param-value>xxx</param-value>
</init-param>
</servlet>
These initialization parameters can be obtained through this.getServletConfig.getInitParameter().
3.javax.servlet.Servlet interface is the basic interface of Servlet, and all defined Servlets must implement this interface. Javax.servlet.GenericServlet is the base class that implements this interface. HttpServlet is inherited from the GenericServlet class. GenericServlet implements the ServletConfig interface, so you can directly call methods in ServletConfig in HttpServlet, such as HttpServlet.getInitParameter(), HttpServlet.getServletName(); HttpServlet.getServletContext() method, etc., without having to use this.getServletConfig.getInitParameter(), etc. method to obtain.
4.Servlet init method:
The init method of the javax.servlet.Servlet interface has parameters. The original method is: init(ServletConfig config) method. After the GeneralServlet class implements the Servlet interface and implements basic functions in the init(ServletConfig config) method, it calls the parameterless init() method for expansion. Therefore, when we inherit the HttpServlet method, we generally rewrite the init method without parameters.
5.Servlet service method:
This method is the main method of Servlet. All requests will be handed over to this method for execution. In HttpServlet, the function of the service method is to hand over the request to doPost, doGet and other methods for processing according to the type of request. So in HttpServlet, you only need to rewrite the doPost, doGet and other methods. If the doService method is rewritten, the doPost and doGet methods will not work.