<c:import> Tag
The <c:import> tag provides all the functionality of the <jsp:include> action tag, and also allows including absolute URLs.
For example, the <c:import> tag can be used to include different web content from an FTP server.
Syntax
<c:import url="<string>" var="<string>" scope="<string>" varReader="<string>" context="<string>" charEncoding="<string>"/>
Attributes
The <c:import> tag has the following attributes:
| Attribute | Description | Required | Default Value |
|---|---|---|---|
| url | The URL of the resource to be imported, can be a relative path or an absolute path, and can also import resources from other hosts. | Yes | None |
| context | When using a relative path to access an external context resource, context specifies the name of this resource. | no | Current application |
| charEncoding | The character encoding set of the imported data | no | ISO-8859-1 |
| var | The variable used to store the imported text | no | None |
| scope | The scope of the var attribute | no | page |
| varReader | An optional variable used to provide a java.io.Reader object | no | None |
Example
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>c:import 标签实例</title>
</head>
<body>
<c:import var="data" url="http://www.example.com"/>
<c:out value="${data}"/>
</body>
</html>
The above program will print the source code of the http://www.example.com page. You can try it yourself.
Other Extensions
JSP Standard Tag Library