指令与动作之include动作
include动作
统一编译
语法:<jsp:include page="URL" flush="true/false"/> page表示要包含的页面,flush表示被包含的页面是否从缓冲区中读取,true表示使用缓冲,false表示不使用缓冲,刚开始默认为false。
注释:缓冲器为暂时置放输出或输入资料的内存。缓冲器内资料自储存设备(如硬盘)来,放置在缓冲器中,须待机送至CPU或其他运算设备。缓冲区(buffer)这个中文译意源自当计算机的高速部件与低速部件通讯时,必须将高速部件的输出暂存到某处,以保证高速部件与低速部件相吻合.
后来这个意思被扩展了,成为"临时存贮区"的意思。
代码:
date.jsp
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
Date d=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");
String s=sdf.format(d);
out.println(s);
%>
action.jsp
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'datetest.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<h1>include动作</h1>
<hr>
<jsp:include page="date.jsp" flush="false"/>
</body>
</html>
include指令与动作的区别