c:out is a tag used to display the result of an expression in the web browser, which works similarly to the way JSP's <%=...%> expression tag works. The only difference is that this tag helps avoid HTML characters so that you can avoid cross-site scripting.

<c:out> Tag Syntax


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


Attribute Required Default Description
value Yes None This attribute is for evaluating expressions and displaying information.
default No Body This attribute is used to display a default value if the resulting value of the <c:out> tag is null.
escapeXml No true This attribute checks whether the '&', '<', and '>' special characters in the resulting string should be converted to their respective HTML entities.

<c:out> Tag Examples

Here is an example where this <c:out> Tag is only displaying information to the web browser:


<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>

<!DOCTYPE html>
    <title>Example of out in core-JSTL</title>
    <c:out value = "${'<p>Example of c:out for Output</p>'}" default="Not Available" escapeXml="true"/>


<p>Example of c:out for Output</p>

Another example where this tag is used to display the result of an expression in the web browser:


The sum of two numbers is: <c:out value="${2+5}" />


The sum of two numbers is: 7

Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram