Static include commands and dynamic Include commands of JSP, jspinclude

Source: Internet
Author: User

Static include commands and dynamic Include commands of JSP, jspinclude

(1) use static include commands

<% @ Page language = "java" contentType = "text/html; charset = gb2312" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = ISO-8859-1">
<Title> Insert title here </title>
</Head>
<Body>
<% @ Include file = "scriptlet. jsp" %>
</Body>
</Html>

(2) Use the dynamic Include command

<% @ Page language = "java" contentType = "text/html; charset = ISO-8859-1"
PageEncoding = "ISO-8859-1" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = ISO-8859-1">
<Title> Insert title here </title>
</Head>
<Body>
<Jsp: include page = "scriptlet. jsp"/>
</Body>
</Html>

The scriptlet. jsp page code is as follows:

<% @ Page language = "java" contentType = "text/html; charset = gb2312" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = ISO-8859-1">
<Title> Insert title here </title>
</Head>
<Body>
<%
Out. write ("from scriptlet. jsp ");
%>
</Body>
</Html>

(3) differences between static and dynamic import:

(1) Static import fully integrates the code on the imported page and the two pages into a complete Servlet. Therefore, the imported page does not need to be a complete page; dynamic import uses the include method in Servlet to introduce the content of the imported page;

(2) During static import, the compilation commands on the imported page take effect. during dynamic import, the compilation commands on the imported page become ineffective, but only the body content of the imported page is inserted.

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.