Introduction to Servlet technology

What is a Servlet?

What is a Servlet?

Servlet is described as:

  • It is a technology which is used to develop web application.
  • It is a class which extends the capabilities of the servers and responds to the request.
  • It is an API which gives number of classes and interfaces.
  • It is a web component which is deployed on the server to develop web page.

CGI (Common Gateway Interface) this is a technology which enables the server to call a program and pass HTTP request information to the program to process the request. It starts a new process for each request. In comparison with the CGI servlets gives many advantages:

  • Portability: Servlets are platform-independent because it uses java.
  • Robust: need not to worry about memory leak, garbage collection etc. because Servlets are managed by JVM.
  • Performance: for each request servlets creates a thread not process.
  • Secure: it uses java language hence it secured.

Servlets Architecture:

In a Web Application the position of Servlets is as shown in below diagram.

Servlets architechture

Servlets Tasks:

The following tasks are performing by Servlets:

  • Read the sent data by browsers which include form of HTML on a Web page or from an applet.
  • Read the HTTP request data sent by the browsers which includes media types, cookies etc.
  • The process of generating the results requires connecting to a database, executing an RMI or invoking a Web service or manipulating the response directly.
  • Send the data like the document to the browsers. This data document can be any of formats like Excel, binary (GIF images), text (HTML/XML) etc.
  • Send the HTTP response to the browsers which includes informing the browsers or clients about the type of document is being returned and caching parameters, setting cookies etc.

In the next part of this guide we will setup our environment to run our example code.


This guide introduces Servlet technology and we will cover below topics

  1. What is a Servlet?
  2. Initial Setup
  3. Life Cycle
  4. Various Examples
  5. Client Request
  6. Server Response
  7. Http Status Codes
  8. Writing Filters
  9. Exception Handling
  10. Cookies Handling
  11. Session Tracking
  12. Database Access
  13. Packaging
  14. Internationalization

This is to the point introduction to the topic to get you started



Working knowledge of Core Java is essential


Beginner to Java Servlet technology or students looking to brush up their skills quickly

Learning Objectives

Learn Java Servlets

Author: Subject Coach
Added on: 2nd May 2015

You must be logged in as Student to ask a Question.

None just yet!