Software & Networking
Previous Page Contents Next Page
 NetForge 1.0 Manual:   Servlet Essentials 

Stefan Zeiger

Servlet Essentials

Version 1.3.4 of April 17, 1999

Covers Servlet API versions 1.0, 2.0 and 2.1


This document explains the concepts of Java Servlets and provides a step-by-step tutorial for writing HTTP Servlets with complete source code for the example Servlets. The tutorial and the other chapters cover all facets of Servlet programming from a simple "Hello World" Servlet to advanced Servlet features like session tracking and Cookies. There are also appendices on compiling and running Servlets. The reader is assumed to have some basic knowledge of HTML and Java programming.

Table of Contents

0. Preface
0.1 About this Document
0.2 Changes
0.3    Style
1. An Invitation to Servlets
1.1 What is a Servlet?
1.2 Servlets vs CGI
1.3 The Basic Servlet Architecture
1.4 HTTP
2. Servlets Step by Step
2.1 Hello World!
2.2 A Form Processing Servlet
2.3 Session Tracking
2.4 An Image Servlet
3. The Servlet Environment
3.1 Inter-Servlet Communication
3.2 Communication with Active Server Resources
3.3 Accessing Passive Server Resources
3.4 Accessing Servlet Resources
3.5 Sharing Data Between Servlets
4. Miscellaneous
4.1 Not Thread-Safe Servlets
4.2 An Application for the Command Pattern
4.3 Client-Side Data with Cookies
4.4 Internationalization
4.5 User Authentication via Sessions
4.6 Relative URLs
4.7 Logging
A. Compiling Servlets
B. Running the Example Servlets with NetForge
C. Servlet Resources on the Internet
D. Glossary
E. Servlet API Changes

0.  Preface

0.1  About this Document

This document is copyrighted © by Stefan Zeiger. You may make an archival copy for personal use. Apart from that it may not be redistributed in part or whole, in electronical, printed or any other form without the author's prior written consent.

Java is a trademark of Sun Microsystems, Inc. Netscape is a registered trademark of Netscape Communications Corporation. All other trademarks mentioned belong to their respective owners.

The latest version of Servlet Essentials can be found online at You can also download a complete archive, including all of the example Servlets:

Version Format Size Download
Servlet Essentials 1.3.4 zip ~81k
tar + gzip ~62k servlet-essentials-1.3.4.tar.gz

Please send feedback to

0.2  Changes

The following changes have been made to this document since version 1.0. Only major revisions are listed. Minor revisions (e.g. 1.0 -> 1.0.1 -> 1.0.2) contain only corrections but no new material.

New in Version 1.3
Restructured the whole document. There are new sections "An Application for the Command Pattern" and "Logging", a new Glossary appendix, a new Servlet API Changes appendix and some minor additions to existing chapters. Several typos and HTML errors have been corrected. Most of the visual design is now done with Cascading Style Sheets (CSS1).

New in Version 1.2
Version 1.2 covers the new Servlet API version 2.1. Annotations about the compatibility of the example programs and descriptions with the different versions of the Servlet API have been added. There is a new section titled "Accessing Server Resources".

New in Version 1.1
Apart from some minor corrections and extensions in the existing sections version 1.1 contains a new section on Internationalization. The "Image Servlet" section has been moved to chapter 2. Several HTML errors were corrected in the Java source code which was previously converted to colored HTML by hand. New source code has been converted automatically with JMarkup.

0.3  Style

Text with different meanings is rendered in different styles throughout this document:

Cascading Style Sheets are used for additional layout and design information. You should use an HTML viewer which understands CSS1 for the best results, but the document can still be used with older viewers.

            Servlet Essentials 1.3.4