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.