Easy Tutorial
❮ Servlet Sending Email Servlet Life Cycle ❯

Introduction to Servlet

What is a Servlet?

A Java Servlet is a program that runs on a web server or application server. It acts as an intermediary layer between requests from web browsers or other HTTP clients and databases or applications on an HTTP server.

Using Servlets, you can collect user input from web forms, display records from databases or other sources, and dynamically create web pages.

Java Servlets often achieve similar results to programs implemented using CGI (Common Gateway Interface). However, Servlets have several advantages over CGI:

Servlet Architecture

The diagram below shows the position of Servlets in a web application.

Servlet Tasks

Servlets perform the following main tasks:

Servlet Packages

Java Servlets are Java classes that run on web servers equipped with interpreters supporting the Java Servlet specification.

Servlets can be created using the javax.servlet and javax.servlet.http packages, which are standard components of the Java Enterprise Edition, an extended version of the Java class library supporting large development projects.

These classes implement the Java Servlet and JSP specifications. At the time of writing this tutorial, the respective versions are Java Servlet 2.5 and JSP 2.1.

Java Servlets, like any other Java classes, are created and compiled. After installing the Servlet packages and adding them to your computer's Classpath, you can compile Servlets using the JDK's Java compiler or any other compiler.

What's Next?

Next, this tutorial will guide you step-by-step in setting up your Servlet environment to start using Servlets. So, buckle up and join us on this journey to learn about Servlets! We believe you will enjoy this tutorial.

❮ Servlet Sending Email Servlet Life Cycle ❯