1 <%@ page language="java" contentType="text/html; charset=GB18030"
2 pageEncoding="GB18030"%>
3 <%@ page import="java.util.Date"%>
4 <%@ page import="java.text.SimpleDateFormat"%> 指令标识
5 <html>
6 <head>
7 <meta http-equiv="Content-Type" content="text/html; charset=GB18030">
8 <title>一个简单的JSP页面——显示系统时间</title>
9 </head> html代码
10 <body>
11 <%
12 Date date = new Date(); //获取日期对象
13 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置日期时间格式
14 String today = df.format(date); //获取当前系统日期
15 %> 嵌入的java代码
16
17 当前时间:<%=today%> <!-- 输出系统时间 --> html注释
18 </body>
19 </html>