略
2.判断时间forward到不同页面:
time.jsp:
复制代码 代码如下:
<%--
document : index
created on : 2009-10-3, 15:48:00
author : lucifer
--%>
<%@page contenttype="text/html" pageencoding="utf-8"%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en"
"http://www.w3.org/tr/html4/loose.dtd">
<%@page import="java.util.date" %>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>jsp page</title>
</head>
<body>
<%
date dat =
new date();
if(dat.gethours() <= 12){
%>
<jsp:forward page="amgreeting.jsp"/>
<%}
else{
%>
<jsp:forward page="pmgreeting.jsp"/>
<%}
%>
</body>
</html>
3.如果是早上:
amgreeting.jsp:
复制代码 代码如下:
<%--
document : amgreeting
created on : 2009-10-3, 16:00:10
author : lucifer
--%>
<%@page contenttype="text/html" pageencoding="utf-8"%>
<!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=utf-8">
<title>jsp page</title>
</head>
<body>
<h1>good morning! </h1>
<%
string name = request.getparameter("username");
out.println(name);
%>
!!!
</body>
</html>
如果是下午:
pmgreeting.jsp:
复制代码 代码如下:
<%--
document : amgreeting
created on : 2009-10-3, 16:00:10
author : lucifer
--%>
<%@page contenttype="text/html" pageencoding="utf-8"%>
<!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=utf-8">
<title>jsp page</title>
</head>
<body>
<h1>good afternoon! </h1>
<%
string name = request.getparameter("username");
out.println(name);
%>
!!!
</body>
</html>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!