Name

<c:out>

Synopsis

The <c:out> action adds the evaluation result of an expression to the current response buffer (JspWriter), or a default value if the main expression evaluates to null. The evaluation result is always converted to a String; it follows the coercing rules described in Appendix C.

Syntax 1: Without a body

<c:out value="expression" [escapeXml="[true|false]"]
  [default="defaultExpression"] />

Syntax 2: With a body

<c:out value="expression" [escapeXml="[true|false]"]>
  defaultExpression
</c:out>

Attributes

Attributename

Java type

Dynamic valueaccepted

Description

value
Object
Yes

The expression to evaluate.

escapeXml
boolean
Yes

If true, the characters < > & ' " are converted to the corresponding XML character entity codes.

default
Object
Yes

The default expression to use if the expression defined by value evaluates to null. If no default is specified, the empty string is used as the ultimate default.

Example

<c:out value="${param.phone}" default="No phone" />
  
<c:out value="${user.imageURL}">
  <c:url value="/defaultUserImage.jpg" />
</c:out>

Get JavaServer Pages, Second Edition 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.