English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The <c:import> tag provides all the functions of the <jsp:include> behavior tag and also allows the inclusion of absolute URLs.
For example, using the <c:import> tag can include different web content from an FTP server.
<c:import url="<string>" var="<string>" scope="<string>" varReader="<string>" context="<string>" charEncoding="<string>"/>
The <c:import> tag has the following attributes:
Attribute | Description | Is it necessary | Default value |
---|---|---|---|
url | The URL of the resource to be imported, which can be a relative path or an absolute path, and it can also import resources from other hosts | Yes | None |
context | When accessing external context resources via relative paths, context specifies the name of this resource. | No | Current application |
charEncoding | Character encoding set of the imported data | No | ISO-8859-1 |
var | Variable used to store the imported text | No | None |
scope | The scope of the var attribute | No | page |
varReader | Optional variable for providing java.io.Reader objects | No | None |
<%@ 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 Example</title> </head> <body> <c:import var="data" url="http://www.oldtoolbag.com"/> <c:out value="${data}"/> </body> </html>
The following program will print http://www.w3Source code of the "codebox.com" page, you can try it yourself.