Learn Java for Web Development

(Tina Meador) #1

130 CHAPTER 3: Best Practices in Java EE Web Development


General-Purpose Actions


The general-purpose actions provide the means to work with scoped variables. Table 3-7 describes
the general-purpose actions in the core tag library.


Table 3-6. JSTL Core Library


Functional Areas Description

General-purpose actions Used to manipulate the scoped variables
Conditional actions Used for conditional processing within a JSP page
Iterator actions Used to iterate through collections of objects
URL-related actions Used for dealing with URL resources in a JSP page

Table 3-7. General-Purpose Actions


Action Description

<c:out> Evaluates an expression and outputs the result to the JspWriter object
<c:set> Sets the value of a scoped variable or a property of a target object
<c:remove> Removes a scoped variable
<c:catch> Catches a java.lang.Throwable thrown by any of its nested actions

The Action


The action evaluates an expression and displays the result. It’s equivalent to the JSP syntax
<%= expression %>.


Here’s the syntax without a body:


<c:out value="value" [escapeXml="{true|false}"][default="defaultValue"] />


Here’s the syntax with a body:


<c:out value="value" [escapeXml="{true|false}"]>
default value


Items in brackets are optional

Table 3-8 describes the attributes of . Since this chapter covers JSTL comprehensively,
I recommend you read the JSTL specification^3 for a thorough understanding of how to use JSTL
attributes.


(^3) http://java.coe.psu.ac.th/J2EE/JSTL1.2/jstl-1_2-mrel2-spec.pdf

Free download pdf