<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
Method1:
<p>
<%@ page import="java.util.*"%>
<%
Date date = new Date();
//System.out.println(date);
%>
hello, the date is
<%=date%><br>
</p>
Method2:
<p>
hello, the date is:
<%@ page import="java.util.*"%>
<%=new Date()%><br>
<%
out.print(new Date());//the same
%>
</p>
Method3: 使用函数
<p>
<%@page import="java.util.*"%>
<%!Date date = new Date();
Date getMyDate()
{
System.out.println("the date is :" + date);// print the result to the console
return date;
}%>
the date is <%= getMyDate() %>
</p>
</body>
</html>