JSTL c:out Core Tag

The JSTL <c:out> Core Tag is used to display the value of an expression to the client’s browser. It works same as of <%= %> (expression tag) or out implicit object or expression language but the difference is that it automatically escape XML tags while others don’t escape XML tags.

Syntax: <c:out value=”value/expression” />

c:out tag attributes:

Attribute Description Required
value Information to output Yes
default Fallback information to output No
escapeXml True if the tag should escape special XML characters No

Example:

test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
<html>
  <head>
	<title>c:out JSTL core tag example</title>
  </head>
  <body>
    <c:out value="This is a c:out JSTL core tag example."/><br/>
    Sum of 10 and 20 = <c:out value="${10+20}"/><br/><br/>
 
    <c:out value="${'<h6>This is a <c:out> escape XML test </h6>'}"/>
  </body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>test.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 31

Download this example.

Next Topic: JSTL c:set Core Tag with example.
Previous Topic: JSTL Core Tags with example.

Related Topics:

JSTL c:out Core Tag with example.
JSTL c:set Core Tag with example.
JSTL c:remove Core Tag with example.
JSTL c:catch Core Tag with example.
JSTL c:if Core Tag with example.
JSTL c:choose , c:when and c:otherwise Core Tags with example.
JSTL c:import Core Tag with example.
JSTL c:forEach Core Tag with example.
JSTL c:forTokens Core Tag with example.
JSTL c:url Core Tag with example.
JSTL c:param Core Tag with example.
JSTL c:redirect Core Tag with example.