Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Introduction to Java Servlet technology

Roy W. Miller (roy@roywmiller.com), Programmer, Independent
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 Java 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.

Summary:  Java developer and trainer Roy Miller revamps our existing introductory servlet material into this single easy-to-follow, hands-on tutorial. Roy introduces explains 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.

Date:  07 Dec 2004
Level:  Introductory PDF:  A4 and Letter (338 KB | 41 pages)Get Adobe® Reader®

Activity:  39433 views
Comments:  

Before you start

About this tutorial

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.


Tools and code

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.


About the author

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.

1 of 9 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=131642
TutorialTitle=Introduction to Java Servlet technology
publish-date=12072004
author1-email=roy@roywmiller.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).