Amazon.com
Aimed at the more experienced Java Web developer,
Advanced JavaServer Pages covers leading-edge techniques for writing more maintainable Web applications in Java. Stressing custom tag libraries and other reusable components, this book is all you need to take your programming skills to the next level.
There are any number of good introductory texts on JavaServer Pages. This title distinguishes itself with techniques recommended by Sun for building better Web applications. Backed up by the author's own collection of custom tag libraries, which allow ordinary Web designers to program with tags instead of Java code, this text covers all the bases from getting started with tags to more advanced techniques. Early examples of tag libraries include a variety of ways to validate data in HTML forms. Throughout, the book deftly describes installing tag libraries, and shows how HTML designers can use custom tags after Java developers have created them.
Readers also get best practices for JSP and Beans, which is a big plus. Author David Geary presents both Model 1 and Model 2 architectures. (In Model 1, JavaBeans are used to present data to front-end JSPs. In Model 2, a more sophisticated set of Java classes using the Model-View-Controller design pattern allows even greater flexibility.) Sample code for using JSP and JavaBeans for internationalized code (including French, German, and Chinese) will show you how to take your Web application to worldwide markets. The book concludes with a working case study of an online fruit stand (using several languages) and applies the techniques presented earlier on.
All in all, with its mix of practical advice and some very useful techniques for getting the most out of JSP and Java for Web applications, Advanced JavaServer Pages fills a valuable niche for any serious Java developer who wants to see some of the best ways to create Web applications today. --Richard Dragan
Topics covered:
- Custom tag tutorial (including JSP and TLD files)
- The tag life cycle
- Tag attributes
- Tag classes
- Body tag handlers
- Scripting variables
- Nested tags
- HTML forms and JavaBeans
- Validating form data with Beans and custom tags
- Templates and custom tags for defining regions within Web pages
- Model 1 and Model 2 basics
- Sample classes and tags for Model 2 framework (including samples for managing logins)
- Event handling
- Sensitive form resubmissions
- Internationalization techniques (including resource bundles and locales)
- Security issues (including basic, digest, form-based, and SSL authentication)
- Custom tags for JDBC database programming
- Database connection pooling, XML, and JavaBeans
- The Simple API for XML (SAX)
- The Document Object Model (DOM) and custom tags for these APIs
- XSLT and XML
- Case study for an internationalized online fruit stand
- Appendix on Servlet filters and the Servlet 2.3 specification
From the Inside Flap
Preface
Shortly after the Swing volume of Graphic Java was published in March 1999, I became aware of the mass exodus from client-side Java to server-side Java. Because I make a living writing books, I took that exodus very seriously, so I began exploring server-side Java in search of a technology that would be appropriate for my next book. At first, I was enamored with XML, XSLT, and Java, and I spent a good deal of time experimenting with those technologies. But as exciting as those technologies are, it seemed to me that they were on the periphery of developing web applications, and I wanted something that was directly involved in the creation of web applications. Then I discovered servlets.
To be honest, I wasn't too excited about servlets. Were software developers really going to create user interfaces by generating HTML with print statements from the guts of some servlet? I knew of at least one software developer that was not. Since 1984, I've had the good fortune to develop software by using a number of object-oriented languages and very cool user interface toolkits. I've developed applications in Smalltalk, Eiffel, and NeXTSTEP, and it seemed to me that developing applications with HTMLespecially HTML manually generated from servletswas akin to trading in a Ferrari for a Yugo. Then I discovered JSP.
Although back in 1999 JSP was in its infancy, it was easy to see its potential. Here was a way to mix Java with HTML, which opened the door to all kinds of interesting possibilities. And in the Future Directions section of the JSP 1.0 specification, I saw something that really caught my eye: A portable tag extension mechanism is being considered for the JSP 1.1 specification. This mechanism permits the description of tags that can be used from any JSP page. Wow. With custom tags you could encapsulate Java code, which would essentially allow you to create custom components, in the form of tags, that could be used in conjunction with HTML. From then on, I knew that my next book would be about JSP.
So I started to write an introductory JSP book, and I actually wrote the first chapter of that book before I realized two things. First, there was going to be a glut of introductory JSP books, and I did not want to compete against all of those books. Second, and most important, that first chapter was boring, and I hate to read boring books, let alone write them. So, I decided to write this book instead.What This Book Is About
As its name suggests, this book is an advanced treatment of JavaServer Pages. The central theme of this book is the design and implementation of flexible, extensible, and maintainable applications with beans, servlets, and JSP.
This book begins where most introductory JSP books leave off, by showing you how to implement JSP custom tags. The ability to create custom tags is arguably JSP's greatest strength because it allows software developers and page authors to work in parallel with few dependencies. Subsequent chapters cover HTML forms, JSP templates, Model 1 and Model 2 architectures, a simple Model 2 framework, handling events, internationalization, security, databases, and XML. This book concludes with a comprehensive case study that shows how to use the techniques discussed in this book to develop a nontrivial web application.The Servlet and JSP APIs This Book Depends Upon
The code in this book depends upon the Servlet 2.2 and JSP 1.1 specifications. Although the Servlet 2.3 and JSP 1.2 specifications were first released in draft form in November 2000, as this book went to press they were still in a state of flux. Because servlet filters are arguably the most important addition to the Servlet 2.3 specification, that topic is covered in "Servlet Filters" on page 471; however, you should be aware that the code in that appendix is very likely to change by the time you read this.How This Book's Code Was Tested
I tested all of the code in this book with Tomcat 3.2.1. If a code example from this book does not work correctly with Tomcat 3.2.1, such as the example in "Digest Authentication" on page 259, that fact is pointed out in the book's text.
Because Tomcat is the reference implementation for the Servlet and JSP specifications, all of the code in this book should work with any servlet container that conforms to the Servlet 2.2 and JSP 1.1 (or higher) specifications. If an example from this book does not work with your servlet container, it is most likely a bug in that servlet container.
I also tested all of the code in this book against Resin 1.2, which is an excellent servlet container available from caucho. As a general rule, it is beneficial to test your code against more than one servlet container to ensure correctness and portability.This Book's Audience
This book was written for Java developers with a basic understanding of servlets and JSP. For most Java developers, this should be their second book that covers servlets and JSP