❮ Previous Next ❯

Servlet API

Servlet API consists two important packages that contains many in-built classes and interface, like:

Some In-built Classes and Interfaces of javax.servlet

Servlet ServletInputStream
ServletContext ServletOutputStream
ServletConfig ServletRequestWrapper
RequestDispatcher ServletRequestAttributeEvent
SingleThreadModel ServletContextAttributeEvent
Filter ServletException
FilterConfig UnavailableException

Some Important Classes and Interface of javax.servlet.http

HttpServlet HttpServletRequest
HttpServletResponse HttpSessionAttributeListener
HttpSession HttpSessionListener
Cookie HttpSessionEvent

Servlet Interface

Servlet Interface provides five methods. Out of these five methods, three methods are Servlet life cycle methods and remaining two methods are apart from life cycle methods.

1,2,3 are servlet life cycle methods and 4,5 non life cycle methods.

GenericServlet Class

GenericServlet is an abstract class that provides implementation of most of the basic servlet methods. Methods of GenericServlet class

• public void init(ServletConfig)
• public abstract void service(ServletRequest request,ServletResposne response)
• public void destroy()
• public ServletConfig getServletConfig()
• public String getServletInfo()
• public ServletContext getServletContext()
• public String getInitParameter(String name)
• public Enumeration getInitParameterNames()
• public String getServletName()
• public void log(String msg)
• public void log(String msg, Throwable t)

HttpServlet class

HttpServlet is also an abstract class. This class gives implementation of various service() methods of Servlet interface.
To create a servlet, we should create a class that extends HttpServlet abstract class. The Servlet class that we will create, must not override service() method. Our servlet class will override only the doGet() and/or doPost() methods.
The service() method of HttpServlet class listens to the Http methods (GET, POST etc) from request stream and invokes doGet() or doPost() methods based on Http method type.

❮ Previous Next ❯

Follow Us


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved