HKJava.com > Java Servlet Programming, 2nd Edition

Title: Java Servlet Programming, 2nd Edition
Author: Jason Hunter, with William Crawford
Publisher O'Reilly & Associates
Publication date: April 2001
ISBN: 0-596-00040-5

Although there are plently of introductory books on Java servlet technology, Java Servlet Programming stands out from the crowd by combining solid, comprehensive coverage of the basics with more advanced but highly useful material that few similar books offer.

The basics are dealt with in chapters one through five, which offer a brief history of Web applications (from the era of CGI and Perl), an introduction to HTTP and servlets, an explanation of servlet configuration and the servlet lifecycle, plus two detailed chapters on working with the HTTP request and response objects respectively. There is also a separate chapter on sending non-HTML content, and another on working with cookies and sessions.

The highlight of the second edition, and the aspect that most sets Java Servlet Programming apart from other books, is the in-depth discussion of content-generation technologies. Here, the authors go beyond the core servlet API, and devotes no less than five chapters to freely-available add-ons that ease the task of generating web pages, typically HTML. Although Sun's JavaServer Pages is currently the most popular servlet-based presentation technology, it is by no means the only solution, and the authors make a strong case that it is not always the best. In addition to JSP, there are chapters on the Tea framework, WebMacro, the Element Construction Set, and Enhydra's XMLC. While each of these technologies has its own strengths and weaknesses, each aims to provides a way to generate output that is superior to out.println in terms of maintainability, reuse and so forth. The authors stop short of discussing full-blown MVC frameworks such as Struts, but that's understandable since the extra material would probably have turned the book, already close to 800 pages, into a two-volume set.

Another highlight is the chapter on applet-servlet communication. While neither applets nor servlets are particularly hard to develop in themselves, building a system that coordinates the two is not trivial, and stumps plenty of programmers who are new to developing Web-based applications with Java. This chapter actually discusses three ways of getting an applet to talk to a server, namely low-level sockets, HTTP, and RMI, of which only HTTP actually requires the use of servlets. In addition to plentiful example code, the pros and cons of the different approaches are laid out clearly. This is a very useful treatment of a topic that few books on servlets discuss.

The book also includes excellent chapters on security, database-driven web applications, the role of servlets in J2EE (including a very good introduction to clustering concepts), and internationalization.

As usual with O'Reilly, there are plently of code examples. The style of the book is very down-to-earth and practical, and the authors clearly know their stuff. The five chapters on content generation alone make this book a must-have for servlet developers. If that includes you, get a copy, even if you have to sell your granny.