JSTL--->core core tag library->url operations

Source: Internet
Author: User

JSTL--->core core tag library->url operations

-->import, param, URL, redirect

<c:import> include static or dynamic files to the JSP page itself

The biggest difference between him and <jsp:include> is that <jsp:include> can only contain files that are the same as their own web application, and <c:import> not just ... You can also include files from different Web application or other Web sites

Syntax 1:

<c:import url= "url" [context= "context"] [var= "VarName"] [scope= "{page|request|session|application}"] [ charencoding= "Charencoding"]>

Ontology content ...

</c:import>

Syntax 2:

<c:import url= "url" [context= "context"] varreader= "Varreadername" [charencoding= "charencoding"]>

Ontology content ...

</c:import>

Property:

URL: The address that the file is contained in

Context: Under the same container, other web platforms must start with/

var: Store the contents of a package file

JSP range C for Scope:var variables

Harencodeing: Encoded format of the included file V

Arreader: Storing the contents of a package file

Give several chestnuts:

1:<c:import url= "http://java.sun.com"/>

<c:import> will add http://java.sun.com content to the Web page

or <c:import url= "Ftp://ftp.cse.yzu.edu.tw/data.txt"/>

2:<c:import url= "hello.jsp"/> hello.jsp with the current page under the same WebApps folder,

If Add/, then jump to the project root directory WebApps below, it is necessary to write <c:import url= "Images/hello.txt"/>

3: If there are different items on the unified server, the included files must be defined in Server.xml, and the Crosscontext property value of <Context> must be true, so that files under others can be called by other Web sites

Called <context path= "/others" docbase= "others" debug= "0" reloadable= "true" crosscontext= "true"/>

<c:import url= "/jsp/index.html" context= "/others"/>

In addition to the,<c:import> also provides the Var and scope properties, its storage will not be output on the page, we can take out when needed

<c:import url= "/images/hello.txt" var= "S" scope= "session"/>

<c:import url= "http://java.sun.com" >

<c:param name= "test" value= "1234"/> </c:import>

It means to include a file that specifies the URL: http://java.sun.com?test=1234

<c:url> used to generate a URL

Syntax 1: No ontology content

<c:url value= "Value" [context= "context"] [var= "VarName"] [scope= "{page|request|session|application}"]/>

Syntax 2: Ontology content

<c:url value= "Value" [context= "context"] [var= "VarName"][scope= "{page|request|session|application}"] > <c: param> Marker </c:url>

Property: Value: The URL to execute

Context: Under the same container, other web platforms must start with/

var: the JSP scope that stores the contents of the contained file Scope:var variable

Chestnuts:

<c:url value= "/http www.javaworld.com.tw" >

<c:param name= "param" value= "value"/> </c:url>

Generated URL: http://www.javaworld.com.tw?param=value

<c:redirect> directs client requests from a JSP file to other files

Syntax 1: No ontology content

<c:redirect url= "url" [context= "context"]/>

Syntax 2: Ontology content

<c:redirect url= "url" [context= "context"] > <c:param> </c:redirect >

Example: <c:redirect url= "http://www.javaworld.com.tw"/> Web page will automatically guide http://www.javaworld.com.tw

Page <c:redirect url= "/jsp/index.html" context= "/others" to other platforms/>

JSTL--->core core tag library->url operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.