Chapter 2. JSP Basics 1: Dynamic Page Creation for Data Presentation

Many of the most popular Web sites in the world are running JSP technology. JSP enables the flexible and dynamic creation of Web pages. For example, in an online community, JSP may be used to create highly personalized pages containing only information that is relevant to a community member. As another example, an online store could use JSP to dynamically create a checkout form with the products in a customer's shopping cart. The possibilities are limited only by the designer's imagination.

This chapter formally introduces the components that make up a JSP page, and thoroughly explores the role of JSP as a dynamic Web page creation technology.

This chapter covers the following topics:

  • The anatomy of a typical JSP page

  • Processing HTML forms with JSP

  • Incorporating the output of JSP fragments

  • Creating a JSP that generates different HTML depending on input

  • Using JSP to create a personalized Web site

Three hands-on examples are presented in this chapter. They introduce new concepts and techniques in JSP programming.

The Anatomy of a JSP Page

Figure 2-1 shows a typical JSP page, with all of its visible elements explicitly labeled.

Anatomy of a JSP page

Figure 2.1. Anatomy of a JSP page

The visible elements that make up a JSP page can include the following:

  • Directive elements

  • Template data

  • Action

  • Scripting elements

A JSP page does not need to have all of these ...

Get Beginning JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.