一、实验目的
这里使用IDEA进行演示
项目结构
<%--
Created by IntelliJ IDEA.
User: 31288
Date: 2023/3/13
Time: 22:27
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%! int cnt;%>
<hr align="center" width="90%" />
<p align="center">
本页面被访问了<%=cnt++%>次。<br/>
信息工程学院版权所有 2023
</p>
运行结果
<%--
Created by IntelliJ IDEA.
User: 31288
Date: 2023/3/13
Time: 22:14
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*,java.text.SimpleDateFormat" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<html>
<head>
<meta http-equiv="content-type" contentType="text/html; charset=UTF-8"></meta>
<title>Include指令的使用</title>
</head>
<body>
<h1 align="center">欢迎来到Java Web社区</h1>
<%
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年M月d日 HH:mm:ss");
String date = sdf.format(new Date());
%>
<h3 align="center">服务器当前时间是<%=date %></h3>
<%@include file="include.jsp" %>
</body>
</html>
运行结果