HttpServlet class

HttpServlet is an abstract class present in javax.servlet.http package. This class is a subclass of GenericServlet class and used widely to create a servlet. Although HttpServlet extends GenericServlet, still there are much differences between them. Differences between GenericServlet and HttpServlet …

Read moreHttpServlet class

GenericServlet Class

Java provides an alternative way to create a servlet in the form of GenericServlet. It is an abstract class present in javax.servlet package that implements Servlet, ServletConfig and Serializable interface. So, now our servlet program needs to extend GenericServlet. Although …

Read moreGenericServlet Class

Asynchronous Servlet

In servlets, each request is handled by a thread. Thus the large amount of threads are required for heavy applications. Sometimes a situation arises when a thread waits for a resource or wait for an event. In this case thread …

Read moreAsynchronous Servlet

Servlet Hidden Form Field

Hidden form field is an invisible field that saves the information regarding the state in client browser. As this information is invisible so client can’t see it but it is visible to servlet. These fields are added to HTML form …

Read moreServlet Hidden Form Field

Servlet URL Rewriting

This is another approach to maintain the session of a user. In this mechanism, when a client make a request then some extra information is appended in the URL of that request. This extra information uniquely identifies a user and …

Read moreServlet URL Rewriting

Servlet Cookie

Cookie is a class that is used for session management. It contains a small amount of information which persists between the server and client.  This information includes name, value and other attributes. Servlet send this information to web browser and …

Read moreServlet Cookie

Servlet HttpSession

HttpSession is an interface used by servlet container to create a session between Http client and Http server. So using this interface we can maintain the state of a user. The object of HttpSession stores various information about the user. …

Read moreServlet HttpSession

Servlet Filter

A filter is an object that is used to obstruct the request and response from server. It has a capability to change the response through Servlet or JSP page. Thus by using filter we can create reusable components. Filter performs …

Read moreServlet Filter

RequestDispatcher

RequestDispacther is an interface used to receive requests from the users and bind it with other files such as HTML file, Servlet file, JSP file etc. Servlet container is responsible to create RequestDispatcher object. RequestDispacther provides forward() and include() methods. …

Read moreRequestDispatcher

ServletContext

ServletContext interface is used to provide the configuration information per web application explicitly. Thus unlike ServletConfig, ServletContext interface can be used to provide information to more than one servlet of web application from web.xml file. So if we want to …

Read moreServletContext

ServletConfig

Servlet container uses the object of ServletConfig interface to provide the information to servlet during initialization. ServletConfig object fetch this information from web.xml file. So if we have to provide some dynamic information to servlet then we can pass it …

Read moreServletConfig

Servlet Request and Response

Servlet handles various client requests and provides their responses. It provides two interfaces i.e ServletRequest and ServletResponse for this purpose. Let’s discuss about these interfaces in detail. ServletRequest interface ServletRequest is an interface whose object is used to provide the …

Read moreServlet Request and Response

Servlet Annotation

Annotations are used to provide the information about the program. In servlets if we don’t want to deploy servlet class configurations in web.xml file then we can use annotations. We can say that annotation removes the requirement of web.xml file. …

Read moreServlet Annotation

Servlet Interface

Java provides a servlet interface in javax.servlet package that is implemented by servlet program either directly or indirectly. This interface provides five methods and these methods must be declared within the servlet program if we are implementing a servlet interface. …

Read moreServlet Interface

web.xml file

Creating a servlet class is not enough. We have to deploy that class also. So, to deploy the class we use web.xml file. In this file we have to map our class configurations.

We just required to edit and …

Read moreweb.xml file

Servlet Packages

There are two packages in Java Servlet that provide various features to servlet. These two packages are javax.servlet and javax.servlet.http. javax.servlet package: This package contains various servlet interfaces and classes which are capable of handling any type of protocol. javax.servlet.http …

Read moreServlet Packages

Life Cycle of Servlet

Servlet container is responsible to manage the lifecycle of a servlet. Servlet provides three methods as a part of its lifecycle. Let’s study the lifecycle of servlets with the following steps. Loading class: This is an initial stage of servlet …

Read moreLife Cycle of Servlet

Servlet Tutorial

Introduction Servlet is a server side Java based programming language widely used to create dynamic web applications. Servlet runs inside a servlet container. It is a portable language so, it will not rely only on one type of web servers. …

Read moreServlet Tutorial