Servlet Learning (1)
1. Servlet is a technology provided by sun for developing dynamic web resources.
2. Servlet location in web applications:
3. Create a Servlet in three ways:
(1) Implement the servlet Interface
(2) InheritanceGenericServlet, override service method
(3) inherit from HttpServle and overwrite doGet () or doPost () methods.
Note:
1>GenericServlet
ImplementedServlet
AndServletConfig
Interface.GenericServlet
Can be expanded directly by a servlet, although it is more general to expand a subclass of a specified protocol, suchHttpServlet
.
GenericServlet
This makes writing to servlets easier. It provides a simple life cycle methodinit
AndDestroy and methods in the ServletConfig Interface
.GenericServlet
Also implementedlog
Method, inServletContext
The API is declared.
2> provides an abstract class for creating HTTP servlrt for a WEB site.HttpServlet
Must override at least one method. Usually one of the following methods: