Go to Home Page


J2EE

About Servlet

Servlet Container

Part of web server interacts with servlet for handling for dynamic web pages from client

Container States
Operations

Servlet API

Deployment Descriptor

More Detalis on Deployment Descriptor

Servlet Interfaces

Servlet interface provides common behaviour to all the servlets. Servlet interface needs to be implemented for creating any servlet [either directly or indirectly). It provides 3 life cycle methods that are used to initialize the servlet, to service the requests, and to destroy the servlet and 2 non-life cycle methods.

Refer Code Here SevletExample.java

Read code comment understand each of life cycle methods

Generic Servlet

Refer code Here GenericServletExample.java

HTTP Servlet

The mostly used approach is by extending HttpServlet because it provides http request

Ref: https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServlet.html Example Code Here Hello.java

Life Cycle of Servlet

Servlet Life cycle

To hands on with servlet and how its working Read and to yourself Servlet Basics Hands-On


Go to Home Page