相思资源网 Design By www.200059.com
1.首页(填写姓名)(可选,表单post到time.jsp即可):
略
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>
略
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>
标签:
JSP,forward
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无JSP forward用法分析实例代码分析的评论...