Datasheet

Patrick c01.tex V3 - 09/18/2009 12:15pm Page 19
Chapter 1: Building Web Applications in WebLogic
JSTL Contains Five Tag Libraries
The JavaServer Pages Standard Tag Library (JSTL) contains the following tag libraries:
The JSTL
core
library contains tags for common operations such as flow control (conditionals,
looping), generating output, setting variables, and creating standard HTML links. Nearly every
application makes use of the core library.
The JSTL
fmt
library contains tags that perform formatting operations such as looking up and
displaying localized messages, generating formatted output using templates, parsing text, and
so on. Many applications use this library.
The JSTL
sql
library provides a tag-based approach for executing SQL statements from within
JSP pages. Because this is rarely a good idea, this library is rarely used.
The JSTL
XML
library provides tags that query and display elements and attributes within XML
documents using the XPath syntax. It can be a viable alternative to using complex XSLT transfor-
mations when trying to display XML data as HTML output.
The JSTL
functions
library contains tags that reproduce the
String
functions available in Java
code. The use of this library should be avoided in favor of performing text-related searches, sub-
strings, or other functions in Java code prior to invoking the JSP page.
A detailed look at the tags, attributes, and correct usage of each of these JSTL libraries is beyond the scope
of this book. The example web application built in subsequent chapters will make extensive use of the
core
and
fmt
libraries within its JSP pages, and there will be ample opportunity at that time to highlight
the important tags and their correct usage.
Best Practice
Plan to use the JSTL
core
and JSTL
fmt
libraries in all of your web applications. These
two libraries provide the most generally useful tags and will be required for all but the
simplest JSP pages.
Use Custom Tags for Selected Behaviors
Custom tags are a powerful mechanism for extending the basic JSP tag syntax to include custom devel-
oped tags for interacting with Java components, modifying response content, and encapsulating page
logic. The JSTL tag libraries discussed previously are good examples of custom tags that can reduce or
eliminate the need for scriptlet code in the JSP page and improve maintainability.
The power of custom tags comes with a cost, of course: complexity. Custom tags add an entirely new
layer to the architectural picture and require a strictly defined set of classes and descriptor files to
operate. Although a detailed description of the steps required to create custom tags is beyond the
scope of this text, it is instructive to review the key concepts to frame the recommendations we will
be making.
19