JSP Tag Libraries
by Gal Schachor, Adam Chace, and Magnus Rydin
Manning Publications Co.
Tag libraries were introduced into the Java specification to solve many of the limitations of using scriptlets (bits of Java code) as part of a JSP page. The main limitation is that advanced page design may require the designer to understand Java to perform tasks such as constructing a loop, if/else blocks, and sending an e-mail, and so on. Art designers and HTML developers are creating many pages in today's Web development environment, making this approach less than optimal. Tags provide a mechanism that will allow a non-Java developer to utilize Java functionality without having to learn the language. Tags can also assist Java developers in separating presentation from control. Tag libraries were introduced as part of the JSP 1.1 specification.
JSP Tag Libraries is published by a small book company (Manning Publications) known for writing books of very good quality. As this publishing company is smaller than the Wroxes and Addison-Wesleys of the world, you may not find it on the local bookstore's shelf, and may have to order it through Amazon or Fat Brain. Reasonably priced at $44.95, it has about 600 pages, divided into 15 chapters. This book doesn't waste your money by selling you freely downloadable Javadocs.
As I started to read, I noticed that the book was very well thought out. It contained only minor typographical errors and had a good flow. This book is not sloppy like others I've read in the past, and I appreciate that the authors actually understand how to use the English language. It doesn't read like a manual but more like a conversation, developer to developer.
Part 1 begins with a light introduction to Web development using Java. It covers how JSPs are developed and goes into sufficient detail on their strengths as well as their limitations. Later chapters cover a tag's life cycle and how it may be used. Typically, an experienced developer may decide to skip over this section, but I recommend reading it, as it also has some hidden gems on JSPs.
Part 2 covers basic techniques on how to develop a tag. The first useful tag that is developed is for sending e-mail. Other tags that are introduced cover interaction with a JavaBean, using tags for validation, assertions, control of flow, as well as accessing the application's back end. Chapter 8, one of the best chapters, covers writing a tag that discovers a JavaBean's methods and events at runtime (reflection), a useful technique for all tag developers.
Part 3 dives into advanced techniques for creating conditional tags to insulate HTML developers from the tricky syntax of creating if/else and loops using scriptlets. Chapter 11 introduces usage of tags with Model 2 architectures. Chapter 12 focuses on using tags in a J2EE environment, and covers usage of EJBs and integration with business logic. There is an awesome discussion on using tags along with JNDI. Within this chapter, two really powerful tags are introduced, one for looking up a bean's home and remote interfaces, and another for connecting to a JDBC data source.
Part 4 covers two different case studies: building a JDBC-driven Web store and an EJB-driven WAP store. Part 5 closes the book nicely with architecture and design advice along with a healthy dose of tips and tricks that will help make your applications reusable, maintainable, and scalable.
I could find only a single flaw in the book: I was hoping there'd be mention of other tag libraries that are a part of many application servers such as WebLogic or JRun, as their libraries are pretty good. I'd especially love to see a chapter or two on the Jakarta tag libraries in a future edition of this book.
JSP Tag Libraries should be part of every developer's library and is worthy of being on the same shelf as UML Distilled, Design Patterns by the Gang of Four, and Inside Servlets by Dustin R. Callaway. This is the first book on this topic that not only covers the nuts and bolts of using tags, but also shows how it can fit into your overall architecture. I look forward to other books by these authors and would recommend them without delay. I rate JSP Tag Libraries only one-quarter star shy of a possible five stars.
Next I'll review Effective Java by Joshua Bloch, published by Addison-Wesley. James Gosling, father of the Java language, mentioned this book during his keynote speech at JavaOne. Let's see if it lives up to its name.