Series: Servlets introduction

Servlets introduction for beginners with explanation, examples and screenshots

RequestDispatcher forward() Example

Communication between the Servlets is an important task to the Programmer. To achieve this, we studied reading private data of a servlet and reading global data by all servlets. Now let us see how to pass data between two servlets (one-to-one) and for this Servlet API comes with javax.servlet.RequestDispatcher interface. When to use RequestDispatcher interface? …

RequestDispatcher forward() Example Read More »

16 Differences include vs forward Decide when to use which?

The javax.servlet.RequestDispatcher interface comes with only two methods of include() and forward(). These methods are discussed very clearly with example code, illustrative figures and explanation in RequestDispatcher include Example and RequestDispatcher forward Example. It is advised to go through these two programs before learning the differences. RequestDispatcher is used whenever the Programmer would like dispatch …

16 Differences include vs forward Decide when to use which? Read More »

What is Session, Session Tracking, Session Management?

For easy understanding, the notes is given in Question/Answer format. 1. What is a Session in Servlets? The interactive time between client and server on a single connection is known as a session. Or The period of time between connection establishment and connection closing between client and server is known as a session. Or Session …

What is Session, Session Tracking, Session Management? Read More »

HTTP Session, HttpSession Methods in Java

Before reading this, it is advised to read the nature of HTTP protocol and what are session, session tracking and JSESSIONID. To maintain HTTP session in Servlets, the Java API comes with javax.servlet.http.HttpSession interface. The methods of this interface are useful to do with session management. session The HttpSession object is capable well to track …

HTTP Session, HttpSession Methods in Java Read More »

Servlet Cookies Simple Shopping Cart Example

Note: You can see the JESSIONID (Session ID) in the output screens at the end. Note: For better understanding, the subject is discussed in Question/Answer format. Note: Before going into this example, it is advised to go through the Cookie API methods and their explanation because these methods are used in this example. 1. What …

Servlet Cookies Simple Shopping Cart Example Read More »

What is ServletConfig interface?

The needs of server-side programming are well thought and architectured by Servlet Designers. If a specific Servlet should be started with some default properties well-suited for certain job, the question is where the properties should be assigned. The properties may change seldom and each time the Servlet should be compiled and deployed is also another …

What is ServletConfig interface? Read More »

What is MIME type in Servlets?

1. What is MIME? MIME is an abbreviation for "Multipurpose Internet Mail Extensions". At the start, email was intended to transport for textual message only and later added attachments etc. These attachments include different files of various formats like images, text files, video and audio etc. To name these extra attachments MIME was introduced. Browsers …

What is MIME type in Servlets? Read More »

sendRedirect() Method Example in Servlet

We have seen earlier, the usage of include(), forward and their 16 differences. Now let us see how to use sendRedirect() method. The sendRedirect(String URL) is defined in javax.servlet.http.HttpServletResponse interface. Let us see what Java API says about sendRedirect() method signature: void sendRedirect(String location) throws IOException: Sends a temporary redirect response to the client using …

sendRedirect() Method Example in Servlet Read More »

View All Servlets

Basic Programs Servlets Introduction, Tutorial, Architecture First Servlet Step-by-Step Explanation – Login Screen Validation 7 Steps – Servlets Tomcat Execution Deployment Descriptor – web.xml Sending dynamically filled HTML form to client Sending static HTML form to Client (sendRedirect) Read all Form data at a time – getParameterNames() Example -I Read all HTML Form Fields at …

View All Servlets Read More »