English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

<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 the <c:out> tag can directly access properties through the "." operator.

For example, if you want to access customer.address.street, you just need to write like this: <c:out value="customer.address.street">.

The <c:out> tag automatically ignores XML marker characters, so they will not be treated as tags.

Syntax format

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

Attribute

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

AttributeDescriptionIs it necessaryDefault value
value Content to be output Yes None
default Default output value No Content in the main body
escapeXml Whether to ignore XML special characters No true

Program 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<c:out> Example/h1>
        <c:out value="<The data object to be displayed (without using escape characters)>" escapeXml="true" default="default value"></c:out><br/>
          <c:out value="<The data object to be displayed (using escape characters)>" escapeXml="false" default="default value"></c:out><br/>
    <c:out value="${null}" escapeXml="false">If the result of the expression used is null, output the default value</c:out><br/>
</body>
</html>

The running result is as follows:

<c:out> Example
<The data object to be displayed (without using escape characters)>
<The data object to be displayed (using escape characters)>
If the result of the expression used is null, output the default value

JSP Standard Tag Library