1 Genericservlet is the implementation class of the Servlet interface and the ServletConfig interface, but an abstract class in which service is an abstract method
2 If the new Servlet program inherits directly from Genericservlet, it will be more concise to develop
3 Specific implementations:
1) This class declares a member variable of type ServletConfig, which is initialized in the Inti (ServletConfig) method.
2) method of implementing ServletConfig interface using ServletConfig member variable method
3) defines an init () method, which is called in the Inti (ServletConfig) method, and subclasses can directly override the Init () method, where the servlet initialization is implemented.
4) It is not recommended to overwrite Init (servletconfig) directly, because if you forget to write Super.init (ServletConfig) and also call the method of the ServletConfig interface, a null pointer exception will occur
5) The new Init () is not the life cycle method of the servlet, and Init (ServletConfig) is the life cycle approach
1 HttpServlet Inheritance Genericservlet
2 convert ServletRequest () and Servletresponse () to HttpServletRequest () and HttpServletResponse () in service () and invoke the overloaded service ( Httpservletrequest,httpservletresponse), using Request.getmethod () in this method to get the request method, call the Doxxx () method
3 actual development, directly inherit HttpServlet, and rewrite the Doxxx () method according to the request method
Genericservlet and HttpServlet