JSTL c:import Core Tag

The JSTL <c:import> Core Tag is used to include the content of other resource at a specific position in the current jsp. It works like include action but the difference is that it can work on relative as well as absolute url while include action can work only on relative url.


<c:import var="varName" url="relUrl/absUrl"/>

c:import tag attributes:

Attribute Description Required
url URL to retrieve and import into the page. Yes
context / followed by the name of a local web application. No
charEncoding Character set to use for imported data. No
var Name of the variable to store imported text. No
scope Scope of the variable used to store imported text. No
varReader Name of an alternate variable to expose java.io.Reader. No



<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
		<title>c:import JSTL core tag example</title>
		<c:import var="data" url="/showInfo.jsp"/>
		<c:out value="${data}"/>


<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
This is a c:import JSTL core tag example.




jsp example 37   Download this example.   Next Topic: JSTL c:forEach Core Tag with example. Previous Topic: JSTL c:choose , c:when and c:otherwise Core Tags with example.


Please follow and like us:
Content Protection by DMCA.com