Before you start
How do the pages you're reading in your favorite Web browser show up there? When you log into your favorite Web site, how does the Web site know that you're you? And how do Web retailers handle taking your order online? Those capabilities are possible because of code running on servers behind the scenes that interact with you in a Web session, access stored information throughout that process, and oftentimes present dynamic information in one or more Web pages. The core of those capabilities is provided in the Java language world by servlets. The goal of this tutorial is to introduce you to servlets. It describes what servlets are, how they work, how you can use them to create Web applications of any degree of sophistication you can imagine, and how you can use servlets most effectively as a professional programmer.
The content of this tutorial is geared toward Java programmers who are unfamiliar, or only vaguely familiar, with servlets. It assumes a general knowledge of downloading and installing software, and a general knowledge of the Java language (creating classes, importing classes, etc.), but doesn't assume knowledge of servlets. The tutorial includes a simple example to illustrate basic servlet concepts, and a more involved example that illustrates more sophisticated use of servlets in a small contact management application.
Should I take this tutorial?
If you've been writing Web apps for a decade, this tutorial is not for you. If you don't know what servlets are, or are only vaguely familiar with them, keep reading. There is much more to servlets than what is included in this tutorial, but this is a good place to start your learning.
You should, however, have the fundamentals of Java programming well in hand. If you're not quite there yet, try my Introduction to Java programming tutorial to get started.
To run the examples or sample code in this tutorial, you'll need to have at least JDK 1.4.2 or higher, along with the Eclipse IDE, installed on your machine. We'll walk through the process of installing the Tomcat plugin for Eclipse, which will allow you to develop servlet applications easily.
All code examples in this tutorial have been tested with J2SE 1.4.2 on the Windows XP platform, but should work without modification using J2SE 1.4.1, or even 5.0.
To install Tomcat, go to the Jakarta Web site (see Resources) and download the binary distribution of Tomcat 5.0.28 (the most current version that works with J2SE 1.4.2, as of this writing). The package comes with a Windows installer that makes installing on that platform a breeze. Follow the instructions in the readme files, and you'll be set.
To install the Tomcat plugin for Eclipse, go to the Sysdeo Web site (see Resources ) and download the plugin zip file (tomcatPluginV3.zip, as of this writing). Then simply extract it to your plugins directory, and follow the instructions at the bottom of the download page to set up the plugin. To be sure your plugin is working correctly, work through the very simple HelloWorld servlet setup "tutorial" that is linked at the bottom of the Sysdeo page (see Resources for a direct link).
Once you have Tomcat and the plugin installed, you're ready to begin this tutorial.
Roy Miller is an independent software development coach, programmer, and author. He began his career at Andersen Consulting (now Accenture), and most recently spent three years using the Java platform professionally at RoleModel Software, Inc., in Holly Springs, NC. He has developed software, managed teams, and coached other programmers at clients ranging from two-person start-ups to Fortune 50 companies.
For technical questions or comments about the content of this tutorial, contact Roy at roy@roywmiller.com.

