GenericServlet class in Servlet

Servlet, Servletconfig and Serializable Interface is implemented by GenericServlet class. Implementation of all these Interface methods besides service method is done by Generic Servlet.It handles request of any kind and runs independently.Generic Servlet can be created by inheriting its class and then implement for service method.

Abstract class is implemented by Service Interface and avoided service method. This abstract class can handle all method of Service interface beside service method.

Methods of GenericServlet

GenericServlet includes all methods of Servlet Interface. Here are methods used in Genericservlet :-

Inheriting GenericServlet class examples :-
import javax.servlet.*;
public class GenericServletDemo extends GenericServlet
public void service(ServletRequest req,ServletResponse resp)
throws IOException,ServletException
PrintWriter out=resp.getWriter();
out.print("<b>Example of GenericServlet</b>");