Easy Tutorial
❮ Jstl Core Catch Tag Jstl Format Setlocale Tag ❯

<c:out> Tag

JSP Standard Tag Library

The <c:out> tag is used to display the result of an expression, similar to <%= %>. The difference is that <c:out> can directly access properties using the "." operator.

For example, to access customer.address.street, you would write: &lt;c:out value="customer.address.street">.

The <c:out> tag automatically ignores XML markup characters, so they are not treated as tags.


Syntax

&lt;c:out value="<string>" default="<string>" escapeXml="&lt;true|false>"/>

Attributes

The <c:out> tag has the following attributes:

Attribute Description Required Default Value
value Content to be output Yes None
default Default output value No Content within the tag
escapeXml Whether to ignore special XML characters No true

Example

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<head>
<title>c:out Tag Example</title>
</head>
<body>
    <h1>&lt;c:out&gt; Example</h1>
        <c:out value="&lt;Data to be displayed (without escaping characters)&gt;" escapeXml="true" default="Default value"></c:out><br/>
          <c:out value="&lt;Data to be displayed (with escaping characters)&gt;" escapeXml="false" default="Default value"></c:out><br/>
    &lt;c:out value="${null}" escapeXml="false">Default value when the expression result is null</c:out><br/>
</body>
</html>

The output will be:

<c:out> Example

&lt;Data to be displayed (without escaping characters)&gt;
&lt;Data to be displayed (with escaping characters)>
Default value when the expression result is null

JSP Standard Tag Library

❮ Jstl Core Catch Tag Jstl Format Setlocale Tag ❯