Find out where you can get the best servlet coverage
Lately, I'm often asked which books on Java servlet and JavaServer Pages (JSP) I would recommend. In fact, even when I was at a local bookstore recently someone asked me that. This month, I'll review five books that focus completely on servlets and four others that contain strong servlet content.
The five books with servlet-only content in this review are:
- Java Servlet Programming, by Jason Hunter with William Crawford
- Developing Java Servlets, by James Goodwill
- Inside Servlets: Server-Side Programming for the Java Platform, by Dustin R. Callaway
- Java Servlets by Example, by Alan R. Williamson
- Java Servlets, Second Edition, by Karl Moss
Table 1 below provides a quick review of the main characteristics of these servlet-specific books.
|Table 1. Servlet-specific books overview|
|Java Servlet Programming||Developing Java Servlets||Inside Servlets||Java Servlets by Example||Java Servlets|
|Publisher||O'Reilly||Sams||Addison Wesley||Manning||McGraw Hill|
|CD-ROM/Source from FTP site||No / Yes||No / No||Yes / No||No / No||Yes / Yes|
|Servlets/JSP Versions covered||2.0 / 0.91||2.1* / 0.92||2.1 / No||2.1 / No||2.1 / No|
|API Reference||Yes (AD)||Yes (AD)||Yes (D)||Yes (AdE)||Yes (Ad)|
|Web Servers||JWS 1.1||JWS 1.1, JRun||JWS 1.1, JRun, ServletExec||JWS 1.1, JRun, ServletExec||JWS 1.1|
The following list explains the meaning of the last several rows in this table. The first group of rows, up to "CD-ROM/Source from FTP site," should be fairly self-explanatory.
- Servlets/JSP Versions: Indicates the latest versions of the APIs the book covers. The Servlets API versions include 1.0, 2.0, 2.1, and the latest, 2.2. The JSP API versions include 0.91 (and earlier), 0.92, 1.0, and the current 1.1 version.
- Sessions: Indicates the book's level of coverage on session management, cookies (the cookie class was added to the 2.0 API), as well as state management.
- Security: Indicates the book's level of coverage on such security topics as HTTP authentication and SSL with servlets.
- XML: Indicates the book's level of coverage on using the Extensible Markup Language (XML) with servlets.
- JDBC: Indicates the book's level of JDBC-servlet connectivity coverage, such as access and connection pooling
- Internationalization: Shows the coverage level for creating Websites that display localized output through servlets, such as date/message formatting, special character set encodings, and use of property files.
- API Reference: Shows whether or not the book includes the complete
javax.servletAPI documentation. An (A) indicates the reference is included in the appendix. A (D) indicates the reference includes long descriptions, and a (d) indicates short descriptions. An (E) indicates the use of examples within the API reference.
- Web Servers: Lists the specific Web servers given a reasonable level of coverage in the book; basically, coverage on how to add a servlet to the Web server is necessary to receive a rating higher than None.
The ranking scale for these topics is None, Poor, Average, Good, Very Good. An asterisk (*) in a field means the review of the specific book provides further details of the ranking.
In addition to the five server-specific books, I reviewed four other books that contain strong servlet content:
- Professional Java Server Programming, by Andrew Patzer et al.
- Professional Java XML Programming with Servlets and JSP, by Alexander Nakhimovsky and Tom Myers
- The Developer's Guide to the Java Web Server: Building Effective and Scalable Server-Side Applications, by Dan Woods, Larne Pekowsky, and Tom Snee
- Core Java Web Server, by Chris Taylor and Tim Kimmet
Table 2 provides a quick review of these books. The table listings are the same as in Table 1 so that the books can be compared. However, you might not want to read these books for the same purpose as those in the previous group.
|Table 2. Non-servlet-specific books overview|
|Professional Java Server Programming||Professional Java XML Programming||Developer's Guide to JWS||Core Java Web Server|
|Publisher||Wrox||Wrox||Addison Wesley||Prentice Hall|
|CD-ROM/Source from FTP site||No / Yes||No / Yes||Yes / No||Yes / No|
|Servlets/JSP Versions||2.1 / 1.0||2.1 / 1.0||2.1 / 1.0||2.1 / 1.0|
|API Reference||Yes (Ad)||Yes (A)||No||No|
|Web Servers||JRun, JWS 2.0, JServ||JSWDK, JRun||JWS 1.1||JWS 1.1|
In the rest of this article, I'll review each book individually. Beside each book's title is a star rating, which is based on the book's overall coverage of servlets. One star is equivalent to a poor rating, and the highest rating (five stars) translates to exceptional coverage of servlets. Most of the books fall in the middle somewhere, and I'll explain why in this next section. I also gave two of the books -- Professional Java XML Programming with Servlets and JSP and Java Servlets by Example -- an N/A rating because I felt it wasn't fair to compare them to other books that concentrated more on teaching servlets. However, for the subjects they do cover, I would give them both four stars.
Book 1: Java Servlet Programming (5 stars)
O'Reilly's Java Servlet Programming, by Jason Hunter, is probably the most popular programming book on Java servlets. What makes this book so good is its breadth of content. If you already know Java and wish to use it to convert your CGI programs or create new ones, this book will put you well on your way to becoming a sought-after Java servlet developer.
In the first half of the book, Hunter lays a good foundation, explaining what servlets are, why they are better than CGI scripts, and how to get started using them. You'll get a basic Hello World servlet program and an overview of the servlet life cycle. You also learn ways to retrieve information about a server, client, or request. Hunter then covers sending HTML and multimedia content responses, including compressed and multipart responses, using Jef Poskanzer's freely available GIF Encoder. (See the Resources section below for more information on the latter.)
Once you get past the basics, Hunter jumps into the more useful topics. The state-management chapter covers how to identify users and manage persistent session information across stateless HTTP requests using hidden form fields, URL rewriting, cookies, and the session-tracking API. The security chapter provides good coverage of authentication and using Secure Sockets Layer (SSL). The Java Database Connectivity (JDBC) chapter provides enough of a primer so that, after reading it you'll be able to connect and retrieve your information, as well as update it and manage transactions -- even if you don't know the JDBC API. While no JDBC 2.0 coverage is provided, you do get a decent discussion of how to pool your database connections from your servlets.
Hunter then moves beyond the specific servlet-usage capabilities into the communication options. For applet-servlet communication, he covers both direct-socket and HTTP-based (tunneling) communications. The meat of the content describes a simple chat application. Unfortunately, the interservlet communication chapter uses many capabilities of the 2.0 Servlet API that are deprecated in the 2.1 API. Once you have your servlets up and running properly, it helps if you can display localized messages to the user.
The book provides some decent discussion of internationalizing your servlets. While the character-set discussion was good, I found the resource-bundle discussion lacking, with less than a page of coverage. The book ends with some odds and ends about using servlets with RMI, debugging servlets, sending email from servlets, and tuning performance. None of these is covered in-depth, but there's enough discussion to give you an idea of how to work better with your servlets.
While he introduces JavaServer Pages (JSPs), Hunter spends only about 10 pages on the topic. The coverage is also based on the version 0.91 -- which is outdated, though still used in IBM's WebSphere. Instead of relying on JSP for HTML generation, some examples in the book use WebLogic's commercial htmlKona package for HTML generation; since it's nonstandard, some might consider this a drawback. The mention of the WebLogic library is short, but the concept of HTML generation is better left to the JSP developer (page designer), rather than the servlet programmer. You shouldn't have to recompile a servlet to change the appearance of a Webpage.
The book also includes a reusable utility library -- one thing that will probably help book sales. If you like the library and want to use it with a commercial development effort, every person on your development team must own a copy of the book. How's that for a selling concept? However, the library has gone through several revisions since the book went to print and is now freely downloadable from Hunter's Website (see Resources).
Don't expect this book to be updated for the 2.1 API. Instead, Hunter states he'll go right to the API 2.2 version. See Resources for details on where to read about the update. In addition, you can find Hunter's JavaWorld articles on the differences between the 2.0 and 2.1 APIs, as well as on the differences between the 2.1 and 2.2 APIs. (As a matter of full disclosure, I should mention that I am an author of an O'Reilly Java book.)
Book 2: Developing Java Servlets (3 stars)
The least expensive servlet-specific book is
Developing Java Servlets
by James Goodwill. In it, you'll find good servlet coverage with a unique discussion of object databases and distributed objects.
Goodwill starts the book in a way that's different from most servlet books. Besides an overview of the servlet architecture and its life cycle, the reader receives an introduction to configuring the servlet development environments -- or at least, what is supposed to be the development environment. First, the book seems confused about what version of the Java Servlet Development Kit (JSDK) it uses. While the book's cover clearly says version 2.1, the text says 2.0 is current. Second, the book doesn't explain how to set up the development environment; it just tells the reader to obtain a JSDK, then quickly moves to configuring the location in which you can deploy servlets. Since the servlet classes are not part of the standard development environment and the chapter is titled "Configuring the Development Environment," I had expected to learn how to configure my environment for servlet development.
After covering the servlet basics, Goodwill moves on to the subjects of retrieving form data and generating HTML output. Instead of using JSP for extensive HTML generation, he introduces his own HTML Object Packager to create the necessary HTML tags, which seem to require excessive object creation. While useful from a purely object-oriented perspective, I found the HTML Object Packager distracting when I tried to learn only about servlets. Also, the HTML generation should be pulled out of the servlet into a JSP file, as the servlet developer shouldn't be worried about page design. The next chapter of the book covers server-side Java and includes another (nonstandard) technology you should avoid in favor of JSP. And considering the book proclaims itself to be updated for JSDK 2.1, it seems odd that it doesn't cover
RequestDispatcher. This class was introduced with the 2.1 API to redirect requests to other resources. The book offers the obligatory chapter on servlet chaining, piping the output of one servlet into the input of another. The applet-to-servlet communication chapter on HTTP tunneling is decent, with a complete GUI-based applet example.
While trying to be different by creating a Swing-based applet to communicate with a servlet, Goodwill unfortunately gets caught with the problem of moving Swing packages (a problem also encountered by many other books). You'll have to change the code to the right package (and install the Java plugin) to get the applet going. In addition, the empty Serializable interface includes a member in its description. After I had what appeared to be a rough start, I started to like this book. Moving into the more advanced topics, you'll find a nice discussion about database connectivity. While the JDBC coverage includes no mention of database transactions, Goodwill does discuss connection pooling, as well as sharing the pool across the
ServletContext, a Servlet 2.1 API-specific capability. I was distracted only by the HTML Object Packager usage, which created pages of code to format a simple HTML table. Besides JDBC-to-servlet connectivity, Goodwill offers a look into using the
ObjectStore object database with servlets, something not often covered in servlet books. (Surprisingly, one of the JWS books -- The Developer's Guide to the Java Web Server -- does so, too; more on that in a moment.)
About halfway through the book, the topics become even more advanced. The first such topic is one not covered in many other books: the packaging of servlet beans. While not long, Goodwill's coverage is more than sufficient to get you started. The JSP coverage is based on the outdated 0.92 specification. Goodwill discusses servlet sessions and security next; specifically, hidden form fields, URL rewriting, cookies, and the session tracking API for sessions, as well as authentication and the use of SSL for security. While SSL is discussed, according to Goodwill the topic is beyond the scope of his book. The remainder of the book provides some real-world examples. There is great coverage of using RMI and CORBA with servlets to create distributed-object clients. In addition, an example is offered of an online movie catalog using the HTML Object Packager and connection pool created in previous chapters. It's a good example; just stay away from the Object Packager-specific code. While the cover lists only one author, Goodwill thanks Steve Wilkinson for writing two of the chapters (on object databases and distributed object clients).
Book 3: Inside Servlets (3 stars)
by Dustin Callaway, is an Addison Wesley offering that is not part of The Java Series. Here, you'll find a good tutorial approach to explaining the Java Servlet 2.1 API.
The book starts out with more basic information than most of the others. Instead of starting with a discussion on Java or servlets, Callaway begins by discussing the Internet. He creates a basic foundation of information on sockets, ports, and standards before moving on to the Web. With the Web basics, you'll learn about URLs, browsers, and CGI. For the more advanced Web foundation, you learn about the HTTP protocol, MIME types, and HTML form tags. All this is presented in the first 65 pages of the 430-page book.
Part II of Inside Servlets is where most other servlet books begin. In Part II, you learn the benefits of servlets and their basic life cycle, and you dissect (but not create) a sample servlet. Subsequently, you attack the Servlet API, with an extended API reference to four of the core classes and interfaces:
HttpServletRequest. By page 137, you are finally able to create your first servlet. Instead of a toy servlet, you create a fully functional bulletin-board servlet and run it in one of the following: JSDK servlet runner, Java Web Server, JRun, or ServletExec. Callaway even discusses servlet development and debugging with such tools as JBuilder and Visual Café before wrapping up Part II with another extended API reference to more classes and interfaces, such as
Part III is where Callaway covers the more advanced topics. Here, you'll find coverage of thread safety as well as HTTP redirection support through setting header fields. The state management chapters cover how to manage persistent session information across stateless HTTP requests with hidden-form fields, URL rewriting, cookies, and the session-tracking API. The server-side include and
RequestDispatcher coverage follows. However, the information on servlet chaining is scarce, compared to the other books. Part III ends with a basic introduction to JDBC connectivity that lacks any mention of connection pooling (or transactions).
The last three parts of the book include three sample servlets, an API quick reference, and appendices. Most people will find the file upload servlet example useful. I'm not as sure about the rest. This book is based on the final 2.1 specification; unfortunately, the final API specification wasn't the final software version. If you happen to get the first or second printing of the book, you'll need to visit the book's errata site (see Resources) for some differences in JSDK 2.1 software file locations.
Book 4: Java Servlets by Example (N/A)
Java Servlets by Example,
from Alan Williamson, offers a different approach to learning about servlets. My opinion of this book is that it does not teach you about the Java Servlet API. Instead, it offers numerous pluggable servlets you can use to replace your CGI scripts. In the process, you'll pick up some tips and tricks for successful servlet development, too.
After introducing you to Java and servlets, Williamson offers information on configuring your development environment (and Web server). Given the target audience of Web designers and CGI scripters, this provides readers with an excellent start to using the rest of the book. Unfortunately, the current development kit requires a different setup. After providing an overview of CGI, Chapters 7 through 25 offer real Web applications that are conventionally developed with CGI scripting languages such as Perl. You'll find a Web counter, quote generator, guest book, quizzes, and more. The last two chapters discuss servlet-specific capabilities, such as communicating with RMI and servlet-to-servlet communications through a shared
ServletContext or with the
RequestDispatcher (clearly using 2.1 API capabilities). I like the book's content, and Williamson clearly has an understanding of how to use the Servlet 2.1 API. However, I just don't see this as a tutorial through which the Java developer can learn the Servlets API. The approach Williamson takes is toward the Web application developer and happens to use these servlet-specific capabilities that weren't explored in the book yet.
What I particularly liked about this book's API reference section were its 143 examples, one for every method of every class; these were not offered by the other books. While they weren't too complicated, they showed a common usage of how readers might call each method. I may be getting picky, but there were a few items that detracted from the overall quality and comprehension of this book. The cover says the book discusses using servlets with JDBG instead of JDBC. One would have thought the cover copy could have at least been proofread. In the table of contents is a reference to the three appendices. You also aren't told what is in each appendix. When quickly reviewing which book to buy at a bookstore, potential buyers will find that the lack of an appendix title detracts from the table of contents' value. I also found the coding style a little distracting, as it doesn't follow the naming conventions followed by Sun and by most other authors. For instance, some class names begin with lowercase letters, and local variable names begin with uppercase letters or inconsistently use Hungarian notation (in which the datatype is part of the variable name).
Book 5: Java Servlets (3 stars)
The first edition of Karl Moss' Java Servlets was the first servlets book to be published that was any good. Unfortunately, the second edition of the book looks like a quick update that includes a few new chapters with minimal changes to the rest. I was disappointed when I saw the update, as I liked the first edition so much.
If you have the first edition of the book, a quick comparison between the two tables of contents reveals the following changes to the second edition:
- Information has been added on adding the servlets jar file to your classpath
- The "JRun" and "Putting It All Together" chapters have been removed
- New chapters on security and session management and added chapters on JavaMail and JNI have been inserted
- The HTTP tunneling chapter is renamed "Applet to Servlet Communications"
The added chapters sound (and are) well and good. However, for the most part, the existing chapters were hardly updated. Moss seems to have assumed that since the old still worked, there was no need to explore whether anything new might work better. For instance, the only mention of the
RequestDispatcher is in the API reference.
The book does have some highlights, however. Given Moss's prior book on JDBC (Java Database Programming with JDBC), the JDBC coverage is good; it includes connection pooling and creating a Type 3 JDBC driver for HTTP tunneling to access a database on the server with its own JDBC driver. While nothing is technically wrong with the explanation on creating the driver, I found this part a bit of overkill for a servlet book, since most database accesses shouldn't be performed from an applet in the first place.
The session management section is good, too. While lacking hidden form field usage (do people still use this?), the chapter includes coverage of session tracking without a browser and working with session events. Both of these topics are rarely covered elsewhere. The security coverage includes HTTP authentication but lacks SSL coverage. The servlet-to-servlet communications content uses the unfavorable manner of accessing specifically named servlets, as opposed to passing information through the ServletContext. The JavaMail API coverage is a nice addition. While most books include a mail-servlet example, many speak SMTP directly to the mail server. In Java Servlets, you get the quick SMTP communications as well as a longer JavaMail example. The API reference in Java Servlets seems to require a quick note. The list of methods for a class is presented twice, with little added value from the duplication. The first is a table summary of the methods. The second is roughly the same information, but not in tabular form. I'm not sure why this information is included twice, but I would drop the table.
So, if you didn't see the first edition, is it worth getting the second? While good, I think you'll do better elsewhere, especially since the book is at the higher end of the price scale.
Book 6: Professional Java Server Programming (5 stars)
The largest and most expensive of the books in this review is
Professional Java Server Programming,
from Wrox. Weighing in at just under four pounds with 15 authors and 1000+ pages, this book covers almost all the server-side Java APIs. While not pushed as a servlet-specific book, there is more coverage of servlets here than in many of the servlet-specific books.
I will not provide an opinion on each of the 27 chapters and 17 appendices. Instead, I'll compare highlights to topics covered in other books, along with a list of all the APIs explored. The introductory servlet content provides a brief setup paragraph and takes you through the core HTTP servlet classes. It also introduces an HTML class for wrapping your HTML generation. This HTML generator class is not used throughout the book, which is probably a result of having so many different authors. The session management coverage is decent, including coverage of cookies and the session tracking API. However, the cookie coverage explains only adding the cookie, not retrieving it, in the text. The more traditional hidden form field and URL rewriting methods are mentioned in passing, though the URL rewriting API is not mentioned, in case you are creating your own dynamic content with URL links included. In addition, there is no mention of session events. Saving state information across servlet contexts is demonstrated, though.
For JDBC coverage, the book includes everything from basic querying to updating, with a review of transaction support and connection pooling. There is even coverage of the JDBC 2.0 extension for connection pools. For servlet communications, you'll find decent content. Servlet chaining is covered for use with the Java Web Server and JRun. (An appendix covers JServ configuration, but not for servlet chaining configuring.) The
RequestDispatcher is covered for forwarding and including content. Serialization is covered but not in the context of servlets. And you'll find an RMI client servlet, but not a server.
The JSP API is discussed over 30 pages that offer nearly everything from an architectural overview to the use of JavaBean components with JSP pages. The use of JSP error pages is also explained. Sending email from servlets is covered with both the JavaMail 1.1.2 API and the
sun.net.smtp.SmtpClient classes. There is also a Webmail servlet provided for reading email that uses the JavaMail API. Professional Java Server Programming includes a nice introduction to XML, with discussions of SAX (Simple API for XML) and DOM (the Document Object Model). This is good content for the JSP and XML developer.
There is a nice chapter on internationalizing Websites with servlets. It discusses using various character encodings like Java Servlet Programming does. Unfortunately, it doesn't mention resource bundles or using any of the
java.text classes to format dates, numbers, and messages.
There are five case studies of server-side Java success stories spread throughout the book. I found these to have varying levels of usefulness. At least they show what can be done with the Java server-side APIs. The security chapter is delegated to an appendix. Unless I missed it, there is no coverage of HTTP authentication or SSL. There is good coverage of cryptography, such as message digests, digital signatures, and the Java Cryptography Extension (JCE); however, the book misses out on the servlet security basics. In the book's many appendices, you will not only find an API reference to the
javax.servlet.http packages (like in most of the other books), but you'll also find an API reference to the JSP, JNDI 1.2, JavaMail, JavaBeans Activation Framework (JAF), Jini, JavaSpaces, EJB 1.1, and JDBC 2.0 classes. Coverage of all these topics is spread throughout the book.
Book 7: Professional Java XML Programming with Servlets and JSP (N/A)
The other Wrox book reviewed isn't one for learning about servlets; hence, I didn't think it fair to rate it based on its servlet coverage. Instead, it is about using XML with Java Servlets and JSP to create three-tier Web applications.
Professional Java XML Programming with Servlets and JSP, by Alexander Nakhimovsky and Tom Myers, starts out with an introduction to three-tier Web applications, using servlets and JDBC. The first servlet example connects you to a database with JDBC and searches for a phone number based on a name submitted from a form. Reading this, you'll soon realize who the target programmer level: someone who is already comfortable developing in Java. One thing worth noting is that the example does use an HTML wrapper class and some other utility classes you'll have to learn about. Later in the book, you'll find a discussion of different approaches to HTML generation, including some based on the Element Construction Set (ECS) library from Apache.
Still working through the first chapter, you'll find an introduction to the servlet API, its life cycle, and session tracking. If you were not familiar with servlets before reading this book, there is enough to get you started. However, the coverage is more of a review of the API than a tutorial on how to use it. In the next couple of chapters, Nakhimovsky and Myers work to create a generalized three-tier application, and then introduce JDBC. The JDBC coverage is minimal, moving quickly into a set of library classes that utilize connection pooling and caching. The generalized application requires a little formal language theory and understanding of grammars and parsers. There is nothing too complicated, but you'll find enough help to get a shopping-cart application going.
After Nakhimovsky and Myers create and explain the foundation for three-tier Web applications, they move on to explaining XML. They explore HTML 4.0.1, XML 1.0, namespaces in XML, associating style sheets with XML documents, XHTML 1.0, XSLT 1.0, and XPath 1.0. Using XML as a Java Serialization format is discussed but not demonstrated. For learning about using XML with Java, the book serves as a good resource. It seems to cover just about everything for learning XML from DTDs to DOM, to processing with SAX and Sun's Java-XML toolkit. One thing not mentioned is the Cocoon XML publishing framework project of The Apache Software Foundation.
Following the book's XML guts is coverage of JavaServer Pages 1.0. The 30-plus pages of JSP syntax in this book are probably the best of the bunch and not limited to the one chapter. A real-world application is also created, utilizing JSP, JDBC, JavaMail, and XML. With the extensive source code included in the book, it's nice to find the source online (see Resources).
Book 8: The Developer's Guide to the Java Web Server (3 stars)
Addison Wesley's other servlet technology title is
The Developer's Guide to the Java Web Server,
by Dan Woods, Larne Pekowsky, and Tom Snee. Like
this is not part of the Java series either. While the book's primary focus is on Java Web Server 1.1 (as opposed to the current 2.0), I found the servlet coverage to be on par with, if not better than, some of the servlet-specific books.
The guide starts out with an introduction to Web development techniques, information on the configuration of the Java Web Server, and a Hello World servlet. The authors proceed with a Hello World JSP example, but they use outdated JSP syntax, unlike a following JSP-specific chapter. There is even a quick session-tracking example thrown in to the first chapter, along with an overview of servlets and servlet life-cycle methods. (Yes, there is quite a bit in that chapter.) Throughout the rest of the book, the authors go through the design of two real-world applications that demonstrate the full capabilities of the Java Web Server: a project-management system and a quizzing program. Both of these are introduced with well-documented code. The administration features of the Java Web Server (JWS) are explored next, from installation of the server, through configuration, and finally to the installation of servlets. Using templates to configure the global site aspect is also explored before the authors give a partial description of JSP 1.0 and how to use it. While you get the JSP basics, items such as JSP error pages are not covered.
Moving on to more advanced servlet API topics, you get a chapter on session tracking. While the authors discuss using hidden form variables and cookies, the chapter focuses on the session management API and demonstrates the use of URL encoding. There is also information on dealing with session-binding events. The authors cover internationalization, discussing resource bundles and message localization. However, there is no coverage on ways to display different character sets.
This leads us to Part III of the book, which is on coding techniques. While the first chapters of the book seemed to throw all the different classes and interfaces at you, this section provides a more in-depth look at many of the same capabilities. There is a partial API reference for many of the core servlet classes, with plenty of sample code. There are discussions on performance tuning, interservlet communications, servlet chaining, and servlet beans. While the 2.1 API
RequestDispatcher is discussed, some deprecated capabilities are used, too. The section continues with additional topics important to servlets, but not part of the Servlets API.
There is a welcome chapter on thread safety, with depth not found in most of the other servlet books. You'll also find coverage of basic socket communications and the JavaMail API. The JDBC coverage includes basic connectivity and connection pooling. There is even coverage of the ObjectStore/PSE object database. Additionally, the book communication between external applications and RMI, CORBA, and even DCOM for Visual J++ users.
Part IV covers application-development techniques, including debugging, stress testing, and performance tuning. Part V finally covers security, but this coverage does not extend to authentication or SSL. Instead, access-control lists and realms are covered. The final chapter is on adding services to the Web server. While presented as a Java Web Server book, you should think of it more as a servlet-specific book. Maybe they'll rename it for the second edition.
Book 9: Core Java Web Server (3 stars)
Core Java Web Server,
by Chris Taylor and Tim Kimmet, introduces you to servlets, it is more about getting the most out of the Web server. It is not for someone interested in learning how to program servlets, although you will discover some servlet content here not currently found elsewhere. And the information in the book is based on an outdated version of the Web server.
Instead of starting with a "What are servlets?" chapter, this book starts with an introduction to the Java Web Server. Installation (and uninstall) details are provided for Windows NT, Windows 95, and Solaris, with some side notes on Linux. Taylor and Kimmet discuss finding the right Java runtime environment for your platform and testing several with the VolanoMark performance benchmark on your specific platform. Next, they walk you through the admin servlet at length, helping you to customize the JWS configuration. After getting JWS up and running, the book goes into exploring servlets. Taylor and Kimmet instruct you on installing the (older) Servlet Development Kit, and explore a handful of generic servlets before moving to more advanced topics.
All along, JWS-specific topics are covered, such as tuning the thread-pool size, autoloading the servlet on server startup, and servlet chaining. The Swing GUI used for the servlet-debugging example, unfortunately, uses the older Swing packages. This requires you to modify the example for it to work properly. Then Taylor and Kimmet cover the HTTP protocol and HTTP servlets. To demonstrate, they provide a commonly used guest-book servlet. They also explore error handling by setting the error-response codes. Since the book is about using the JWS and not about teaching you servlets, the authors explore CGI and the configuration of the server to run CGI scripts. There is an informative benchmark comparing the Perl-based guest book to the servlets version, and you'll also learn how to improve performance through caching with the JWS.
Afterwards, Taylor and Kimmet move back into exploring the more advanced servlet capabilities. The state-management chapter includes decent coverage of cookies, URL encoding, the session-management API, and listening for session events. There is also a section on session persistence for when the server is shut down. To demonstrate session management, a nice LDAP/JNDI example is provided. The book even includes a rare chapter on servlet beans and about 30 pages on JSP.
The book ends with the best servlet security chapter I've seen, with detailed examples of Basic and Digest authentication, as well as a complete example of SSL, including configuring SSL on the Web server. Finally, the book's one appendix compares HTML and XML, and shows how to install a CDF (Channel Definition Format) servlet to make your own channels.
In a nutshell, which book to buy?
Many of the nine books reviewed here contain good servlet coverage.
The two I like best for strictly learning servlets are O'Reilly's Java Servlet Programming and Professional Java Server Programming, from Wrox. While over a year old, Java Servlet Programming is still current enough for readers to learn about the core parts of servlets. While you'll miss out on the newer 2.1 API specifics, it is still a good value at 2.95, compared to Professional Java Server Programming's 9.99. For just learning servlets, Wrox's Professional Java Server Programming is overkill, but for the additional cost you get much more on server-side programming; it's also one of the few books with decent JSP coverage. Developing Java Servlets (Sams) is good (and cheap), but some problems throughout the book make me give it a thumbs down. Java Servlets (McGraw-Hill) is also good, but for just a few more dollars, you can get so much more with Professional Java Server Programming. New to market is Professional Java XML Programming with Servlets and JSP from Wrox. While this book is not meant to teach you servlets, the XML coverage provides a better way to use servlets with JSP.
Before rushing out to buy one, keep in mind the fact that all the JSP books are already out of date, as the JSP specification is currently at 1.1. (At least the XML book mentions some of the differences.) One thing I learned from reviewing all these books is I don't have to write my own book on servlets. While the JSP coverage is mostly lacking in them, these books should help you become a better servlet developer.
The authors of this month's server-side Java computing articles will be holding a free online seminar on March 9 at 10:00 a.m. PST. Register to join at http://seminars.jguru.com.
Learn more about this topic
- Jef Poskanzer's ACME GIF Encoder
- Java Servlet programming examples
- Licensing terms for
- Information from Jason Hunter on next edition of Java Servlet Programming: http://archives.java.sun.com/cgi-bin/wa?A2=ind9912&L=servlet-interest&F=&S=&P=126274
- "What's New in Java Servlet API 2.2?" Jason Hunter (JavaWorld, October 1999)
- "Introducing the New Servlet API 2.1," Jason Hunter (JavaWorld, December 1998)
- Inside Servlets updates
- Source code from Professional Java Server Programming: http://apache.wrox.co.uk/projsp/
- Source code from Professional Java XML Programming with Servlets and JSP: http://www.wrox.com/Consumer/Store/Download.asp?ISBN=1861002858
- Java Servlets source
- Developing Java Servlets source
- VolanoMark Java benchmark
- The Cocoon XML publishing framework
Server-side Java: Read the whole series -archived on JavaWorld
- Welcome to the server-side Java series
- Understanding JavaServer Pages Model 2 Architecture
- Create forward-compatible beans in EJB, Part 1
- Create forward-compatible beans in EJB, Part 2
- Use JDBC for industrial-strength performance, Part 1
- Use JDBC for industrial-strength performance, Part 2
- Counting tiers - one, two, or n?
- Build distributed applications with Java and XML
- Internationalize JSP-based Websites
- Patterns for flexible initialization, Part 1
- Patterns for flexible initialization, Part 2
- Advanced form processing using JSP
- Using XML and JSP together
Learn how the implementation of static analysis at Intuit led to reduced technical, improved code...
The major new features in Java 8 center around lambda expressions, a functional programming construct...
Geir Magnusson Jr. gets you started with using the Velocity Template Engine and the Velocity Template...
Popular updates like Project Jigsaw and the new JSON API get the hype, but Java 9 promises a goldmine...
As Oracle presses forward with Project Jigsaw, it is notifying developers of potential changes to apps...
Application architectures keep evolving. APIs and microservices are the latest style and make...
Storm lets you create real-time analytics for every conceivable need. Here's a tasty example using...
Streem could end up being the basis for future Ruby upgrades, while Mochi brings key functional...