CHAPTER 3: Best Practices in Java EE Web Development 131
The value to be written to the JspWriter is specified as a value attribute. You can use expressions in
the value attribute.
value: The expression to be evaluated is supplied via the value attribute,
and the result is converted into a string before being returned as part of the
response.
default: You can optionally specify a default value that <c:out> sends to the
current JspWriter if the specified value is null or is not a valid expression. You
can specify the default value with the default attribute or in the body of the
<c:out> action.
escapeXml: The escapeXml attribute specifies whether to convert certain
characters to the HTML character entity codes listed in Table 3-9. By default, the
escapeXmlattribute is set to true. If you specify false for the escapeXml attribute,
<c:out> will not convert these characters.
Table 3-9. Character Entity Codes
Character Character Entity Code
< <
> >
& &
' '
" "
Table 3-8.
Name Type Description
value Object This is the expression to be evaluated.
escapeXml boolean This determines whether the characters <,>,&,’,” in the
resulting string should be converted to their corresponding
character entity codes. The default value is true.
default Object This is the default value if the resulting value is null.
Listing 3-35 illustrates replacing scripting elements with the
Listing 3-35. Comparing
<%= "hello" %> // Ouput "hello" using Expression