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:

AttributeDescriptionRequired
valueInformation to outputYes
defaultFallback information to outputNo
escapeXmlTrue if the tag should escape special XML charactersNo

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.

 

Content Protection by DMCA.com
Please Share