📄 index.jsp
字号:
<%-- page指令是定义了一系列与JSP页面相关的属性并且使它们与JSP引擎进行通信 --%>
<%@ page language="java" %> <%-- 脚本所用语言 --%>
<%@ page contentType="text/html;charset=gb2312" %> <%-- 定义JSP页面的字符编码和对应的MIME类型 --%>
<%@ page errorPage="errorpage.jsp" %> <%-- 定义捕捉例外的对应脚本,当有例外时,自动跳转到此页面 --%>
<%@ page import="java.util.*" %> <%-- 装载Java的特定类库 --%>
<html>
<head>
<title>利用Cookie实现身份验证</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.tableline { border-color: #CE00CE #ce00ce #ce00ce; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
.buttonline { background-color: #FFFFFF; border-color: #8080FF #8080ff #8080ff; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
-->
</style>
</head>
<body bgcolor="#FFFFFF">
<table width="100%" border="0" class=tableline>
<tr>
<td height="91">
<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td> </td>
</tr>
<tr>
<td>
<div align="center"><font face="方正姚体" size="+3" color="#7777BB">欢迎光临<font face="方正舒体" size="+5">梦幻</font>网</font></div>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<%
String HelloWords = null;
Date now_datetime = new Date(); // 实例一个Date对象
int currHour = now_datetime.getHours(); // 取当前的小时
/* 判断用户访问网页的时间并且给出不同的问候语 */
if((currHour >= 0) && (currHour <= 6))
{
HelloWords = "Hi,It's midnight. The current time is: " + now_datetime.toLocaleString();
}
if((currHour >= 7) && (currHour <= 10))
{
HelloWords = "Good Morning. The current time is: " + now_datetime.toLocaleString();
}
if((currHour >= 11) && (currHour <= 12))
{
HelloWords = "Good Noon. The current time is: " + now_datetime.toLocaleString();
}
if((currHour >= 13) && (currHour <= 17))
{
HelloWords = "Good Afternoon. The current time is: " + now_datetime.toLocaleString();
}
if((currHour >= 18) && (currHour <= 24))
{
HelloWords = "Good Evening. The current time is: " + now_datetime.toLocaleString();
}
if(HelloWords == null || HelloWords.length() < 1)
{
HelloWords = "Hello. The current time is: " + now_datetime.toLocaleString();
}
%>
<td height="2"><font size="2" color="#009900"><b><%=HelloWords%></b></font></td>
</tr>
<tr>
<%
String UserIP = null;
UserIP = request.getRemoteAddr(); // 获取用户的IP地址
%>
<td><font size="2" color="#009900"><b>欢迎来自<%=UserIP%>的朋友!</b></font></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<form method="post" action="http://127.0.0.1/chapter5/regist.jsp">
<div align="center"><font face="幼圆" color="#FF9933" size="4"><i><b>如果您是第一次光临本站,请先注册</b></i></font><b><i><font color="#FF9933" size="4">:</font></i></b><font color="#FF9933" size="4">
<input type="submit" name="SubmitRegist" value="注 册" class=buttonline>
</font> </div>
</form>
</td>
</tr>
<tr>
<td>
<div align="left"><font size="2" color="#009900"></font></div>
</td>
</tr>
<tr>
<td height="2">
<form method="post" action="http://127.0.0.1/chapter5/login.html">
<div align="center"><font face="幼圆" color="#FF9933" size="4"><i><b>如果您已经是注册的会员,请先登录</b></i></font><b><i><font color="#FF9933" size="4">:</font></i></b><font color="#FF9933" size="4">
<input type="submit" name="SubmitLogin" value="登 录" class="buttonline">
</font> </div>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -