Javaserver Pages





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
JSP Tutorial
Introduction Introduction
Installing JDK-Windows Installing JDK-Windows
Installing JDK-Linux Installing JDK-Linux
Installing Tomcat Installing Tomcat
Simple Program in JSP Simple Program in JSP
Pre-defined Variables Pre-defined Variables
Syntax of Tags Syntax of Tags
JSP Expression Language JSP Expression Language
JSP EL Operators JSP EL Operators
EL Implicit Variables EL Implicit Variables
Scopes Scopes
Using Arrays Using Arrays
Methods Methods
JSP Elements JSP Elements
Including Beans Including Beans
JSTL Tags JSTL Tags
Custom Tags Custom Tags
Session Session in JSP
Handling Cookies Handling Cookies
JSP Application Structure JSP Application Structure
Configuring web.xml Configuring web.xml
Tomcat Configuration Tomcat Configuration
JSP Examples JSP Examples
Forums Ask Your Doubts
Feedback Feedback
 




import tag in JSP Core Tag Library


Tutorials Jsp

Topic

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



Explanation

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.

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

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 = "http://java.sun.com/jsp/jstl/core" prefix = "c"%>
   <p>Use of c:import in jstl</p>
   <c:import url="fulldate.jsp"/>
     <p>Date displayed from full date.jsp::</p>
   </c:import>

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.




A Note
JSP(Java Server Pages) is one of the most used Server Side Programming Language in the world. Simple introduction, basic program codes with examples. Begin coding your own JSP scripts with this online tutorial. Hope you enjoy this tutorial. Do send your feedback or suggestions on this JavaServer Pages tutorial. This is a copyright content.


Other Links

web hosting