JSTL XML x:out Tag

The <x: out> tag is used to display the result of xml path expression and writes result to the jsp writer object.

Syntax Of <x: out> Tag

<x: out attributes/>

Attributes Of <x: out> Tag

  • select: To evaluate the particular object it specifies xml Xpath expression.
  • escapeXML: Accepts special character an convert it to their corresponding character entity code. The default value is true.


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


 <title> x:out Tags</title>


<h2>Fruits Information:</h2>

<c:set var="fruit">






<x:parse xml="${fruit}" var="output"/>
<b>The name of the fruit</b>:

<x:out select="$output/fruits/fruit[1]/name" /><br>

<b>The price of the orange</b>:

<x:out select="$output/fruits/fruit[3]/price" />


Details of the Code

  • <c:set var=”fruit”> tag is used to set the variable name which we want to display in the output.
  • <x:out select=”$output/fruits/fruit[1]/name” /> tag is used to display the particular fruit name in the output.
  • <x:out select=”$output/fruits/fruit[3]/price” /> tag is used to display the price of the particular fruit which we want.

Steps for Execution

Before executing the xml programs we should add jar files namely: xalan-2.7.0.jar

  • Save this file as example.jsp in your eclipse IDE.
  • Now select this jsp file, right mouse click and select Run as ->Run on server


When the execution process is completed successfully we will get the following output :
x out tag output

Previous Tutorial : JSTL XML Tags Library :: Next Tutorial : JSTL XML x:forEach Tag

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!