import tag in JSP Core Tag Library

What is "import" tag in JSP Core Tag Library?


The import tag of the core tag library can be used to include file or content within the application or from outside the web application. This is the main advantage of "<c:import" compared to "jsp:include" tag.


<c:import [url="url"] [context="externalContextPath"]
[var="var"] [scope="page|request|session|application"]
Optional <c:param> actions

In the above syntax the "url" attribute stores the url, "context" attribute is optional can give a context name that is usually perpended to the url, <c:param is used to customize the parameters needed from file or url.

Example :

<%@ taglib uri = "" prefix = "c"%>
<p>Use of c:import in jstl</p>
<c:import url="fulldate.jsp"/>
<p>Date displayed from full date.jsp::</p>

Following is the code of "fulldate.jsp" file

<%@page contentType="text/html" import="java.util.*" %>
<p>Current time</p>
<%=new java.util.Date() %>

In the above example we have imported the file "fulldate.jsp" to display the current date value, one can also use "c:<param" to get only specific parameters.

Ask Questions

Ask Question