3/23/2024 2
Jakarta Servlet
Methods
Servlet
Classes
Servlet
Interface
Servlets API
S E R V L E T
Servlet API
Servlet API contains a number of classes and interfaces that describe the contracts between a
servlet class and the runtime environment provided for an instance by a conforming servlet
container.
Servlet API provides the following two packages that contain its classes and interfaces:
javax.servlet.*; Classes and interfaces defines the contracts between a Servlet class and the
runtime environment provided for an instance of such a class by a conforming
Servlet container.
javax.servlet.http.*; Classes and interfaces defines the contracts between a Servlet class running under
the HTTP protocol and the runtime environment provided for an instance of such a
class by a conforming Servlet container.
Servlet Serialization
Servlet Config
Generic Servlet
Http Servlet
User Defined Servlet
INTERFACES
BUILD IN CLASSES
Generic Servlet Abstract Class
 GenericServlet implements Servlet interface
 It defines Servlet generic and independent of protocols
 It doesn’t give implementation for service method of Servlet interface
 If your Servlet Generic class, then it should implement service method
Generic Servlet Abstract Class
Method
Generic Servlet Abstract Class
Method
Http Servlet Abstract Class
Method
init
service
destroy
getServletInfo
getServletConfig
Init method is called by Servlet container to indicate to a Servlet
that it is being placed into service.
Declaration:
void init(ServletConfig config)
init
service
destroy
getServletInfo
getServletConfig
Service method is called by the Servlet container to allow the
Servlet to respond to a request.
Declaration:
public void service(HttpServletRequest req, HttpServletResponse
res) throws ServletException, java.io.IOException
init
service
destroy
getServletInfo
getServletConfig
Destroy method indicates that the Servlet is being taken out of
service
Declaration:
public void destroy()
init
service
destroy
getServletInfo
getServletConfig
getServletInfo method returns information about the Servlet
Declaration:
public String getServletInfo()
init
service
destroy
getServletInfo
getServletConfig
Returns a ServletConfig object that contains initialization and
start-up parameters for this Servlet
Declaration:
public ServletConfig getServletConfig()
Thank You

2.2 Servlet API about enterprise edision resourse programing.pptx