JavaServer Pages

By Hans Bergsten
3rd Edition, December 2003
ISBN: 0-596-00563-6
764 pages
Reader Reviews
Errata
Sample Chapter
What’s New in the 3rd Edition?

See also: JavaServer Pages Pocket Reference

JavaServer Pages (JSP) has built a huge following since the release of JSP 1.0 in 1999, providing Enterprise Java developers with a flexible tool for the development of dynamic web sites and web applications. While new point releases over the years, along with the introduction of the JSP Standard Tag Library (JSTL), have incrementally improved the rough areas of the first version of the JSP specification, JSP 2.0 takes this technology to new heights.

JavaServer Pages, Third Edition, is completely revised and updated to cover the JSP 2.0 and JSTL 1.1 specifications. It includes detailed coverage of the Expression Language (EL) incorporated into JSP 2.0, the JSTL 1.1 tag libraries and the new function library, the new tag file format that enables custom tag library development without Java code, the simplified Java tag library API, improvements in the JSP XML syntax, and more. Further, it details setup of the Apache Tomcat server, JSP and JSTL syntax and features, error handling and debugging, authentication and personalization, database access, XML processing, and internationalization.This book recognizes the different needs of the two groups of professionals who want to learn JSP: page authors interested in using JSP elements in web pages, and programmers concerned with learning the JSP API and using JSP effectively as a part of an enterprise application. If you’re in the first group, you’ll learn from the practical web application examples in the second part of the book. If you’re in the latter group, you’ll appreciate the detailed coverage of advanced topics in the third part, such as how to integrate servlets and JavaBeans components with JSP using the popular Apache Struts MVC framework, and how to develop custom tag libraries using the JSP API, with realistic examples that you can use as a springboard for your own libraries.

“Hans Bergsten, a JSP expert group veteran and one of our most active contributors, has thoroughly and accurately captured the new features of JSP 2.0 and JSTL 1.1 in a way that is well-organized and easy to understand. With excellent, to-the-point examples, this book is a “must-have” for any serious JSP 2.0 developer.”
–Mark Roth, JSP 2.0 Specification Lead, Sun Microsystems, Inc.

 

Table of Contents

Part I: JSP Application Basics

Chapter 1, Introducing JavaServer Pages

  • What Is JavaServer Pages?
  • Why Use JSP?
  • What You Need to Get Started

Chapter 2, HTTP and Servlet Basics

  • The HTTP Request/Response Model
  • Servlets

Chapter 3, JSP Overview

  • The Problem With Servlets
  • The Anatomy of a JSP Page
  • JSP Processing
  • JSP Application Design with MVC

Chapter 4, Setting Up the JSP Environment

  • Installing the Java Software Development Kit
  • Installing the Tomcat Server
  • Testing Tomcat
  • Installing the Book Examples
  • Example Web Application Overview

Part II: JSP Application Development

Chapter 5, Generating Dynamic Content

  • Creating a JSP Page
  • Installing a JSP Page
  • Running a JSP Page
  • Using JSP Directive Elements
  • Using Template Text
  • Using JSP Action Elements

Chapter 6, Using JavaBeans Components in JSP Pages

  • What is a Bean?
  • Declaring a Bean in a JSP Page
  • Reading Bean Properties
  • Setting Bean Properties

Chapter 7, Using Custom Tag Libraries and the JSP Standard Tag Library

  • What is a Custom Tag Library?
  • Installing a Custom Tag Library
  • Declaring a Custom Tag Library
  • Using Actions from a Tag Library

Chapter 8, Processing Input and Output

  • Reading Request Parameter Values
  • Validating User Input
  • Formatting HTML Output

Chapter 9, Error Handling and Debugging

  • Dealing With Syntax Errors
  • Debugging a JSP Application
  • Dealing With Runtime Errors

Chapter 10, Sharing Data Between JSP Pages, Requests and Users

  • Passing Control and Data Between Pages
  • Sharing Session and Application Data
  • Online Shopping
  • Memory Usage Considerations

Chapter 11, Developing Custom Tag Libraries as Tag Files

  • Creating and Using a Tag File
  • Accessing Attribute Values
  • Processing the Action Body
  • Processing Fragment Attributes
  • Exposing Data to the Calling Page Through Variables
  • Aborting the Page Processing
  • Packaging Tag Files for Easy Reuse

Chapter 12, Database Access

  • Accessing a Database From a JSP Page
  • Validation Complex Input Without a Bean
  • Using Transactions
  • Application-Specific Database Actions

Chapter 13, Authentication and Personalization

  • Container-Provided Authentication
  • Application-Controlled Authentication
  • Other Security Concerns

Chapter 14, Internationalization

  • How Java Supports Internationalization And Localization
  • Generating Localized Output
  • A Brief History of Bits
  • Handling Localized Input

Chapter 15, Working with XML Data

  • Generating an XML Response
  • Transforming XML into HTML
  • Transforming XML into a Device-Dependent Format
  • Processing XML Data

Chapter 16, Using Scripting Elements

  • Using Page Directive Scripting Attributes
  • Implicit JSP Scripting Objects
  • Using Scriptlets
  • Using Expressions
  • Using Declarations
  • Mixing Action Elements and Scripting Elements
  • Dealing with Scripting Syntax Errors

Chapter 17, Bits And Pieces

  • Buffering
  • Including Page Fragments
  • Global Configuration Options
  • Mixing Client-Side and Server-Side Code
  • Precompiling JSP Pages
  • Preventing Caching of JSP Pages
  • Writing JSP Pages as XML Documents
  • How URIs Are Interpreted

Part III: JSP in J2EE and JSP Component Development

Chapter 18, Web Application Models

  • The Java 2 Enterprise Edition Model
  • The MVC Design Model
  • Scalability

Chapter 19, Combining JSP and Servlets

  • Servlets, Filters, and Listeners
  • Picking the Right Component Type for Each Task
  • Initializing Shared Resources Using a Listener
  • Access Control Using a Filter
  • Centralized Request Processing Using a Servlet
  • Using a Common JSP Error Page

Chapter 20, Developing JavaBeans Component for JSP

  • Beans as JSP Components
  • JSP Bean Examples
  • Unexpected <jsp:setProperty> Behavior

Chapter 21, Developing Custom Tag Libraries

  • Developing Simple Tag Handlers
  • Developing Classic Tag Handlers
  • Developing Tag Library Functions
  • Creating the Tag Library Descriptor
  • Packaging and Installing a Tag Library

Chapter 22, Advanced Custom Tag Library Features

  • Developing Cooperating Actions
  • Validating Syntax
  • Using a Listener in a Tag Library
  • Dynamic Attribute Values and Types

Chapter 23, Integrating Custom Code with JSTL

  • Setting and Using Configuration Variables
  • Integrating Custom Conditional Actions
  • Integrating Custom Iteration Actions
  • Integrating Custom I18N Actions
  • Integrating Custom Database Access Actions
  • Using JSTL Tag Library Validators

Chapter 24: Database Access Strategies

  • JDBC Basics
  • Using Connections and Connection Pools
  • Making a Connection Pool Available to Application Components
  • Using a Generic Database Bean
  • Developing Application-Specific Database Components

Part IV: Appendixes

Appendix A: JSP Elements Reference
Appendix B: JSTL Actions and API Reference
Appendix C: JSP Expression Language Reference
Appendix D: JSP API Reference
Appendix E: Book Example Custom Actions and API Reference
Appendix F: Web Application Structure and Deployment Descriptor Reference

Index

2 thoughts on “JavaServer Pages

  1. Martin Herdeis on said:

    Hello Hans,

    how is it going? I hope everthing is alright with you in this pandemic situation!
    I am studying your JSP book and I have a question to the shopping example. In
    public Map getProductsById() {
    return catalog;
    }
    you expose a reference to the catalog to the outside world? Is that not a reference that deserves being protected as an essential internal part of the catalog bean? Is there a way to that with an Iterator and an Iterator-Factory interface?
    Thank you for this book,

    Martin

    • Hi Martin,

      I’m fine, and I hope the same is true for you.

      You’re right about this method exposing a reference to an important internal object, and depending on the context, that may not be a good idea. The method must return a Map (to be accessible to EL expressions), but you could return a reference to a copy of the catalog Map instead. In this case, the bean is used in an application that I have total control over so I don’t worry too much; there is no way the bean can be accessed by hostile code. If this was a bean that was intended to be used in application I do not control, e.g. as part of an e-commerce product sold to third parties, I would protect the reference better.

      I hope that helps,
      Hans

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>