In late 1996, Java on the server side was coming on strong. Several major software vendors were marketing technologies specifically aimed at helping server-side Java developers do their jobs more efficiently. Most of these products provided a prebuilt infrastructure that could lift the developer's attention from the raw socket level into the more productive application level. For example, Netscape introduced something it named "server-side applets"; the World Wide Web Consortium included extensible modules called "resources" with its Java-based Jigsaw web server; and with its WebSite server, O'Reilly Software promoted the use of a technology it (only coincidentally) dubbed "servlets." The drawback: each of these technologies was tied to a particular server and designed for very specific tasks.
Then, in early 1997, JavaSoft (a company that has since been reintegrated into Sun Microsystems as the Java Software division) finalized Java servlets. This action consolidated the scattered technologies into a single, standard, generic mechanism for developing modular server-side Java code. Servlets were designed to work with both Java-based and non-Java-based servers. Support for servlets has since been implemented in nearly every web server, from Apache to Zeus, and in many non-web servers as well.
Servlets have been quick to gain acceptance because, unlike many new technologies that must first explain the problem or task they were created to solve, servlets are a clear solution to a well-recognized and widespread need: generating dynamic web content. From corporations down to individual web programmers, people who struggled with the maintenance and performance problems of CGI-based web programming are turning to servlets for their power, portability, and efficiency. Others, who were perhaps intimidated by CGI programming's apparent reliance on manual HTTP communication and the Perl and C languages, are looking to servlets as a manageable first step into the world of web programming.
This book explains everything you need to know about Java servlet programming. The first five chapters cover the basics: what servlets are, what they do, and how they work. The following eight chapters are where the true meat is--they explore the things you are likely to do with servlets. You'll find numerous examples, several suggestions, a few warnings, and even a couple of true hacks that somehow made it past technical review.
We cover Version 2.0 of the Servlet API, which was introduced as part of the Java Web Server 1.1 in December 1997 and clarified by the release of the Java Servlet Development Kit 2.0 in April 1998. Changes in the API from Version 1.0, finalized in June 1997, are noted throughout the text.
Is this book for you? It is if you're interested in extending the functionality of a server--such as extending a web server to generate dynamic content. Specifically, this book was written to help:
0.1.1. What You Need to Know
When we first started writing this book, we found to our surprise that one of the hardest things was determining what to assume about you, the reader. Are you familiar with Java? Have you done CGI or other web application programming before? Or are you getting your feet wet with servlets? Do you understand HTTP and HTML, or do those acronyms seem perfectly interchangeable? No matter what experience level we imagined, it was sure to be too simplistic for some and too advanced for others.
In the end, this book was written with the notion that it should contain predominantly original material: it could leave out exhaustive descriptions of topics and concepts that are well described online or in other books. Scattered throughout the text, you'll find several references to these external sources of information.
Of course, external references only get you so far. This book expects you are comfortable with the Java programming language and basic object-oriented programming techniques. If you are coming to servlets from another language, we suggest you prepare yourself by reading a book on general Java programming, such as Exploring Java, by Patrick Niemeyer and Joshua Peck (O'Reilly). You may want to skim quickly the sections on applets and AWT (graphical) programming and spend extra time on network and multithreaded programming. If you want to get started with servlets right away and learn Java as you go, we suggest you read this book with a copy of Java in a Nutshell, by David Flanagan (O'Reilly), or another Java reference book, at your side.
This book does not assume you have extensive experience with web programming, HTTP, and HTML. But neither does it provide a full introduction to or exhaustive description of these technologies. We'll cover the basics necessary for effective servlet development and leave the finer points (such as a complete list of HTML tags and HTTP 1.1 headers) to other sources.
Copyright © 2001 O'Reilly & Associates. All rights reserved.