Home > Store

Advanced JavaServer Pages

Register your product to gain access to bonus material or receive a coupon.

Advanced JavaServer Pages

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2001
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-030704-1
  • ISBN-13: 978-0-13-030704-0

  • Design and implement flexible, extensible, and maintainable applications with servlets and JSP technology
  • Master powerful authentication and internationalization techniques
  • Learn how to integrate industry-standard XML and XSLT with JSP technology
  • Use JSP technology-based templates to develop robust applications from modular components

Advanced JavaServer Pages delivers:

  • Web application design techniques based on JSP and servlets technology
  • Proven strategies for achieving enterprise-class robustness and scalability with JSP technology
  • Expert guidance on implementing JSP technology-based applications with reusable components

To fully exploit the power of JavaServer Pages technology in Web application development, based on J2EE technology, you need to master the sophisticated server-side techniques that David Geary presents in Advanced JavaServer Pages.

Geary tackles JavaServer Pages technology with the same exhaustive, authoritative approach that made his Graphic Java books into worldwide best sellers. He presents in-depth coverage of advanced topics including:

  • Implementing custom JSP technology tags
  • Designing scalable and extensible Web applications
  • Using authentication to build secure JSP technology-based applications
  • Internationalizing JSP technology-based applications for global environments

Advanced JavaServer Pages features detailed chapters on internationalization, authentication, JSP technology templates, design, and XML. It concludes with a comprehensive case study that ties together key topics developed in the book and demonstrates how to integrate advanced techniques based on JSP technology. This book is a must-have resource for every developer of Java technology creating server-side applications with JSP technology and servlets.

Downloads

Downloads

Download the code associated to this book. (zipped .jar file)

Sample Content

Online Sample Chapters

Advanced JavaServer Pages Security

Java Servlet Authentication

Downloadable Sample Chapter

Table of Contents
Chapter 4
Chapter 9

Table of Contents



Preface


Acknowledgements


1. Custom Tag Fundamentals.

Using Custom Tags-The JSP File. Defining Custom Tags-The TLD. Implementing Custom Tags-Tag Handlers. Specifying the TLD in WEB-INF/web.xml. The Tag Life Cycle. Thread Safety. Tags with Attributes. Accessing Page Information. Error Handling. The Tag Package. The Tag Interface. The TagSupport Class: Ancestors, Values, and Ids. Tags with Bodies. Conclusion.



2. Custom Tag Advanced Concepts.

Body Tag Handlers. The BodyTag Interface. The BodyTagSupport Class. Iteration. Scripting Variables. Storing Beans in Page Scope. Specifying Scripting Variable Information. Associating a Tag Handler and Scripting Variables. Using Custom Tag Ids. Body Content. Understanding How Body Content Works. Generating JavaScript. Nested Tags. Locating Ancestor Tags. Sharing Data. Conclusion.



3. HTML Forms.

Forms with Beans. Transmission of Form Data. Textfields, Text Areas, and Radio Buttons. Checkboxes and Options. Validation Client-side Validation with JavaScript. Server-side Validation with JSP. Server-side Validation with Servlets. Server-side Validation with Servlets and JSP Pages. A Form Framework. Facade Design Pattern for HTML Forms. The Framework. Selectable Elements. Validation. Custom Tags. Conclusion.



4. Templates.

Encapsulating Layout. Sections, Regions, and Templates. Optional Content. Role-based Content. Defining Regions Separately. Nesting Regions. Extending Regions. Combining Features. Region Tag Implementations. The Beans. The Tag Handlers. Conclusion.



5. Design.

Model 1. Model 2: An MVC Approach. A Model 2 Example. The Beans. The Deployment Descriptor. Successful Login Use Case. Creating a New Account. Conclusion.



6. Framework.

A Model 2 Framework. The Action Interface. The Action Factory. Action Routers. The Action Servlet. Retrofitting the Original Model 2 Example. Refining the Design. Adding Use Cases. Step #1: Implement a Password Hint Action. Step #2: Implement a Password Hint JSP. Step #3: Add Mappings to the Properties File. Step #4: Modify the Login Failed JSP Page. The Importance of Custom Tags. JSP Scripts. Conclusion.



7. Event Handling and Sensitive Form Resubmissions.

Event Handling for a Model 2 Framework. Sensitive Form Resubmissions. Trapping Form Resubmissions with a Model 2 Framework. Trapping Form Resubmissions Without a Framework. Conclusion.



8. I18n.

Unicode. Charsets. Non-Latin-based JSP Pages. Multilingual JSP Pages. Locales. Resource Bundles. List Resource Bundles. Using Constants for Resource Keys. Property Resource Bundles. Multiple Resource Bundles. A Bundle Cache. Formatting Locale-Sensitive Information. Dates and Times. Numbers, Currency, and Percents. Messages. Browser Language Preferences. Detecting Locales. Locating Resource Bundles. Custom Tags. A Message Tag. A Format Tag. Conclusion.



9. Security.

Servlet Authentication. Principals and Roles. Declarative Authentication. Portability. Types of Authentication. Basic Authentication. Digest Authentication. Form-Based Authentication. SSL and Client Certificate Authentication. Customizing Authentication. Resin. Tomcat 4.0. Web Application Security Elements. Programmatic Authentication. Conclusion.



10. Databases.

Database Creation. Data Sources. Database Custom Tags. The Query Tag. The ColumnNames Tag. The Columns Tag. The Rows Tag. The Release Tag. Connection Pooling. Using a Connection Pool. Creating a Connection Pool. Implementing a Simple Connection Pool. A More Capable Resource Pool. Prepared Statements. Transactions. Scrolling Through Result Sets. Conclusion.



11. XML.

Generating XML. Generating XML with Beans. Beans That Generate Their Own XML. Generating Beans from XML. Postprocessing XML. Parsing XML. Simple API for XML (SAX). SAX Custom Tags. Document Object Model (DOM).DOM Custom Tags. Transforming XML. Using JSP and XSLT Together. Using XSLT in a Custom Tag to Produce HTML. Using XSLT to Produce JSP at Compile Time. Using XSLT at Compile Time Vs. Runtime. Using Xpath. Conclusion.



12. A Case Study.

The Fruitstand. The Homepage. Going Shopping. The Storefront. The Shopping Cart. The Checkout. The Purchase. The Model 2 Framework. A The Model. The Views-JSP Pages and Templates. The Controllers-Servlets and Actions. Internationalization. Authentication. HTML Forms. Sensitive Form Resubmissions. SSL. XML and DOM. Conclusion.



Servlet Filters.


Index.

Preface

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 HTML—especially HTML manually generated from servlets—was 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 http://www.caucho.com. 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. If you are new to servlets and JSP, I recommend the following books for your first book on those topics:

  • Core Servlets and JSP by Marty Hall, Sun Microsystems Press
  • Java Servlet Programming by Jason Hunter, O'Reilly
  • Web Development with JavaServer Pages by Fields and Kolb, Manning

It also won't hurt to have a basic understanding of design patterns and the Unified Modeling Language (UML). This book demonstrates how to implement a number of design patterns in JSP-based web applications and uses UML class and sequence diagrams to show how classes are related and how they interact, respectively. See page 181 for a list of resources on design patterns and UML.

This book was not written for page authors. If you are a page author with no Java experience, you will be better served by one of the books listed above.

How This Book Was Written

Designing object-oriented software is very much an iterative process. You start with a few classes and build on them, all the while iterating over classes, both old and new, as you integrate them to build an ever-evolving system. In object-oriented parlance, that process is known as refactoring.

After working for 15 years as a software engineer, I tend to write books the way I write software. Each of this book's chapters started out in humble fashion. And each chapter was subsequently refactored into the final product that you hold in your hands.

You can get a glimpse into this process by looking at a JavaWorld article that I wrote about JSP templates. That article is the first cut of this book's Templates chapter, so you can see where the process started for that chapter and where it ended; both the chapter and the code that it discusses underwent much refactoring.

How To Use This Book

This book is not a novel, so I don't expect anyone to sit down and read it cover to cover. Because most readers will read chapters out of order in a random fashion, nearly every chapter in the book can stand on its own. There is one exception to that rule. Chapter 6, which discusses a simple Model 2 framework, depends on Chapter 5, which introduces the Model 2 architecture. Chapter 6 retrofits an example from Chapter 5; therefore, Chapter 5 is a prerequisite for Chapter 6.

The last chapter in this book is a comprehensive case study that employs the techniques discussed throughout this book to implement a nontrivial web application. You can read (or most likely, skim) that chapter first to get a feel for those techniques, or you can read it last to see how to integrate those techniques. Or you can do both.

This Book's Custom Tag Libraries

This book discusses the implementation of approximately 50 JSP custom tags, ranging from internationalization tags to tags that use XML's Document Object Model to parse XML. There are no legal restrictions whatsoever on those tags, so you are free to use those tags in any manner you deem appropriate. See "This Book's Code" on page xvii to see how you can download those tags.

This book's custom tags serve two purposes. First, they illustrate how you can implement your own custom tags. Second, they serve to reinforce the concepts discussed throughout this book. But those custom tags are not the focus of this book; rather, it's the concepts that those tags embody that are important. For example, if you look at the internationalization chapter, you will see that most of that chapter is dedicated to internationalizing text, numbers, dates, and currency in a JSP-based web application. The last few pages of that chapter show how to implement two custom tags that perform internationalization. But it's the internationalization concepts, and not the custom tags, that take center stage in that chapter.

This Book's Code

You can download all of the code from this book, including the book's custom tag libraries, from the following URL:

http://www.phptr.com/advjsp

Index

Download the book's index.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020