Core Java Web Server with Cdrom
Authors: Christopher Taylor, Tim Kimmet
Venue:  (1998)

From the Book:PREFACE: PREFACE All of this started in the Spring of 1997 when we took a Java programming course at San Jose State University, taught by the Java God himself, Dr. Cay Horstmann. As a term project, we were given the task of writing a client/server application in Java. As fortune would have it, the Java Web Server made its public beta debut only weeks before the class project teams formed. Our team quickly moved through the developer documentation and example programs, set up our own RMI/JDBC data server, wrote several servlets using that data server, and had the entire system up and running within two weeks. By the way, we got an "A+" for the project. So what is this anecdote doing in the introduction to our book on the Java Web Server? First, it gives you, as the reader, an idea of our own experience with the Java Web Server. As you'll find in the chapters to come, we approach topics with the attitude of "show me, don't tell me", using numerous code examples and experimental tricks to dig into topics ranging from web security to the popular JSP scripting language. We won't "forget to tell you" about problems we've encountered; instead, we walk you through repeating the same (non-trivial!) mistakes we made when we first developed with the servlet API. This candid view of the "darker side" of servlet development is worth the price of the book alone (at least, it would have been to us when we took that course; half of our time was spent head-scratching over "Document contains no data" messages coming from the Java Web Server)! The last two words of our anecdote, "two weeks," should open some eyes to another exciting benefit with the JavaWebServer: rapid server-side application development. By building on the expertise of the developers at JavaSoft, our team was free to focus on the problem at hand: how to get student resumes from a backend database into the web browsers of prospective employers. All of this coolness was made possible by the Java platform's promise of "make the simple things easy, and make the difficult things possible," which clearly shows through in the design of the servlet API. Putting the religion aside for a moment, consider how the introduction of Java applets sparked an explosion on the Web; documents became living, breathing entities, adding interactive capabilities atop a non-interactive protocol like HTTP. SERVLETS PROMISE THE SAME BREAKTHROUGHS ON THE SERVER SIDE Like their applet cousins, servlets can be compiled once and run on any servlet-compatible system. The servlet API separates the idiosyncrasies of a particular web server from the task of "getting the user's requests processed to send back proper results". If you're anything like us that's all you wanted to accomplish anyway (who wants to become an expert on a particular web server just to write some server-side scripts?). That's where this book comes in. It acts as a tour guide, taking you past the paved roads of the API documentation and deep into the jungle of undocumented programming territory. WHO SHOULD READ THIS BOOK? That's a good question. The most obvious audience is programmers who want to write applications with the Java Web Server. And even if you aren't writing servlets just for the JWS, the knowledge you'll take away from reading this book applies to any servlet-enabled web server, whether it be Apache, Netscape Enterprise Server, or Microsoft's Internet Information Server (just to name a few). Of course, we don't expect you to have a strong knowledge of web servers or servlet programming before reading this book. This book was written with this third group in mind, the Java programmers who want to break out onto the web and write some really cool stuff, but don't know how to make it happen. Hopefully, you'll find everything you need to know about web servers and how to extend them with Java between these covers. Good luck! WHAT YOU'LL NEED You'll need a Java-compatible operating system. Personally, we like Windows NT (the entire book, except for certain installation chapters, was written on Windows NT), with its native threading support and responsive GUI. Windows 95 works too, but it's not very stable (especially when things go wrong-can you say "GPF?") If you're a Unix fan, Solaris or Linux would be a good choice. As for software, most of it can be found on the CD-ROM (see the section "About the CD-ROM" for more info). We've included the latest JDK (1.1.6) for Win32 and Solaris platforms, but you'll want to check the JavaSoft web site (www.javasoft.com) for the latest and greatest version. You'll also need a copy of the Java Web Server. As we're big proponents of "try before you buy", we've included a trial version of the Java Web Server (with the JSP extensions) on the CD-ROM. So, to reiterate, you'll need: Java-compatible O/S Java Development Kit compatible with JDK 1.1 Java Web Server HOW THIS BOOK IS ORGANIZED Just as any developer should know the underlying operating system for which he develops programs, we feel that you should know the Java Web Server Web server inside and out before you actually attempt to extend its features. This requires that you know what features are offered through the web server as well as how to administer its capabilities. In the first part of this book, we introduce you to features and show you how to administer the Java Web Server. Chapter 1 explains many of the features offered under the Java Web Server as well as its underlying architecture. Chapter 2 shows you how to install the Java Web Server on different platforms, including Windows NT, Windows 95, Solaris, and Linux. Even though Chapter 4 reads "Administering The Java Web Server", the administration really begins in Chapter 3, "Alternative Lifestyles For The Java Web Server," where we show you how to configure the JWS to use different virtual machines. Finally, in Chapter 4 we show you how to configure JWS by walking you through different scenarios in the Admin Applet. In the second part of the book, we show you how to extend the JWS. In order to extend the features of the Java Web Server, you'll need to get comfortable with the Java Servlet API, which allows you to write server-side programs that run in the Java Web Server. Chapters 5 and 6 introduce you to the Mother of all Servlets, the GenericServlet class. We cover the API as well as pinpoint some of the problems that we've encountered while developing our own applications. In order to be effective on the Web, you'll need to get familiar with the HTTP-specific Servlet classes offered by the Servlet API. What is HTTP? Glad you asked! Chapter 7 introduces you to HTTP and gives you a clear understanding of all the HTTP 1.1 methods, so that you'll be ready for Chapter 8, where you'll learn about HTTP-specific Servlet development. In Chapter 9, we focus on the differences between CGI and Servlets and show the CGI developer how easy it can be to make the transition from CGI to the more efficient Servlet alternative. Chapters 10 and 11 show you how to implement more advanced features of HTTP, including caching and session management. Chapter 12 gives an introduction to the JWS component model, which is very similar to the JavaBeans component model. Chapter 13 introduces you to JavaServer Pages, which is the latest technology introduced by the Java Web Server team. Finally, in Chapter 14, we provide extensive coverage of the security features under JWS. The fun does not end with Chapter 14, however! Appendix A gives extensive coverage to topics that make JWS even more powerful, namely SGML, XML, and HTML. In our (not-so!) humble opinion, the XML coverage in this chapter is better than most complete references we've seen! CONVENTIONS USED IN THIS BOOK We've tried to stay away from fancy sidebars and shaded areas throughout the book, mainly because we put all of the meaty stuff you'd find in those places in the text itself! When we did use sidebars, they were for a special reason. That reason is apparent from the title of the sidebar. Notes are for providing additional information on a topic without requiring an illustrating example. Design Patterns explain certain portions of the software architecture by comparing them to well-known software patterns, like those found in pattern catalogs like the G4 text (Design Patterns, Gamma et al.). Bugs describe inconsistencies we've found between the printed documentation and reality. Bugs should be taken in context, as they might be ironed out in a later release of Java Web Server. Alerts are like Bugs, except that we've included a suitable workaround for the problem we encountered. ABOUT THE CD-ROM The CD-ROM contains all of the source code examples in the book (organized by chapter), the latest version of the Java Developer's Kit, and trial versions of the Java Web Server for both Solaris and Win32 systems. In addition, we've put some "goodies" on the disc, like Tim's favorite editor (med), the coolest HTML editor on the planet (DreamWeaver), two XML parsers written in Java, third-party servlet runners (JRun and ServletExec), various standards documents for RFC's referenced in the book, and the latest Java Foundation Classes from JavaSoft.