Chapter 6. JSP Tag Libraries and JSTL

During the detailed examination of JSP's expression language (EL) in the last chapter, you saw that it is almost impossible not to use JSTL in conjunction with EL. In fact, the JSP Standard Tag Library (JSTL) and EL are so highly integrated that they are almost always mentioned as one entity by developers.

JSP developers can readily extend the capability of their Web applications by making use of tag libraries. A tag library makes a set of new tags available to your JSP programs. JSTL is the most commonly used library by JSP developers. It adds essential features to JSP, such as conditional flow control and iteration, that enable JSP programming without the need for embedded Java code.

This chapter introduces the basics of the tag library extension mechanism in JSP. It also examines JSTL in detail. The chapter explains the following concepts:

  • What a tag library is

  • Why you need tag libraries

  • How to use a tag library

  • Tag library packaging

  • The Tag Library Descriptor (TLD)

  • JSTL named variables

  • JSTL control flow

  • JSTL iteration

  • JSTL formatting tags

  • JSTL custom functions

To provide some hands-on experience with JSTL, the chapter features a real-world example. The example involves the conversion of an e-commerce site originally programmed using extensive scripting (embedded Java code) to one that uses only JSTL. This is a very common activity in production JSP programming. Developers are frequently asked to maintain or migrate legacy JSP code to the new JSP 2.0 ...

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.