?? admin_login.jsp
字號(hào):
<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %>
<%@ page import="java.util.*" %>
<%request.setCharacterEncoding("GBK");%>
<jsp:useBean id="admin" scope="page" class="admin.admin" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<link rel=stylesheet href="../css/library.css" type="text/css">
<title>圖書(shū)管理系統(tǒng)</title>
</head>
<body>
<%
//從SESSION中獲取密碼嘗試次數(shù)
String tryPwd=(String)session.getAttribute("tryPwd");//從SESSION中獲取密碼嘗試次數(shù)
String supervisor=(String)session.getAttribute("supervisor");//從SESSION中獲取管理員ID
String randCode=(String)session.getAttribute("randcode");//獲取產(chǎn)生的驗(yàn)證碼
String randText=request.getParameter("randText");//獲取輸入的驗(yàn)證碼
String submit=request.getParameter("submit");
String tips=null;
int showTips=0;
int intTryPwd;
if(tryPwd==null)
{
tryPwd="0";//初始化密碼嘗試次數(shù)
intTryPwd=0;//初始化密碼嘗試次數(shù)
}else{
intTryPwd=Integer.parseInt(tryPwd);//將從SESSION中獲得的密碼嘗試次數(shù)從String轉(zhuǎn)為Int
}
if(submit!=null)//判斷是否提交表單,管理員帳號(hào)或密碼是否為空
{
if (intTryPwd < 3 || randCode.equals(randText)) //密碼嘗試次數(shù)小于三次或驗(yàn)證碼正確才允許下一步
{
if(admin.adminLogin(request)){
//設(shè)置Session失效時(shí)間
session.setMaxInactiveInterval(-1);
//將管理員的ID寫(xiě)進(jìn)SESSION中
session.setAttribute("supervisor",request.getParameter("adminId"));
//將驗(yàn)證碼設(shè)置為空
session.setAttribute("randcode","");
//將密碼嘗試次數(shù)設(shè)置為空
session.setAttribute("tryPwd","0");
//提示登陸成功
showTips=2;
tips="<br />登錄成功,2秒后自動(dòng)跳轉(zhuǎn)到管理首頁(yè)!<br />如果沒(méi)有自動(dòng)跳轉(zhuǎn),請(qǐng)點(diǎn)擊<a href=admin_welcome.jsp>管理首頁(yè)</a>進(jìn)入!<br /> ";
//自動(dòng)跳轉(zhuǎn)返回管理首頁(yè)
response.setHeader("Refresh","2;url=admin_welcome.jsp");
}else{
showTips=1;
tips="帳號(hào)或密碼錯(cuò)誤!";
intTryPwd=intTryPwd+1;//密碼嘗試次數(shù)加1
session.setAttribute("tryPwd",Integer.toString(intTryPwd));//在session里放置密碼嘗試次數(shù)
}
}
}
%>
<form id="form" name="form" method="post" action="admin_login.jsp">
<%if(supervisor==null){%>
<table cellpadding=0 cellspacing=0 border=0 width=550 bgcolor="#2E79BE" align=center>
<tr>
<td><table cellpadding=3 cellspacing=1 border=0 width=100%>
<tr>
<td colspan="2" height="22" bgcolor="#6CA6D5" align=center>
管理員登錄</td>
</tr>
<%if(showTips!=2){%>
<tr bgcolor="#DCEFFA">
<td width="33%" align="right" height="30">管理編號(hào):</td>
<td width="67%"><input name="adminId" id="adminId" size="20" maxlength="20"> </td>
</tr>
<tr bgcolor="#DCEFFA">
<td width="33%" align="right" height="30">管理密碼:</td>
<td width="67%"><input name="adminPwd" type="password" id="adminPwd" size="20" maxlength="16"> </td>
</tr>
<%if(intTryPwd>1){//判斷是否應(yīng)該顯示驗(yàn)證碼%>
<tr bgcolor="#DCEFFA">
<td width="33%" align="right" height="30">驗(yàn)證碼:</td>
<td width="67%"><input name="randText" type="text" id="randText" size="10" maxlength="4">
<img src="randcode.jsp" width="60" height="20"> </td>
</tr>
<%}%>
<%}%>
<%if(showTips!=0){%>
<tr bgcolor="#DCEFFA">
<td height="30" colspan="2" align="center"><%=tips%></td>
</tr>
<%}%>
<%if(showTips!=2){%>
<tr>
<td colspan="2" height="15" bgcolor="#6CA6D5" align=center>
<input name="submit" type="submit" id="submit" value="確 定">
<input name="cancel" type="reset" id="cancel" value="重 寫(xiě)"> </td>
</tr>
<%}%>
</table>
</td>
</tr>
</table>
<%}else{%>
<table cellpadding="0" cellspacing="0" border="0" width="550" bgcolor="#2E79BE" align="center">
<tr>
<td><table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr>
<td width="100%" height="22" align="center" bgcolor="#6CA6D5">錯(cuò)誤</td>
</tr>
<tr bgcolor="#DCEFFA">
<td height="30" align="center">您已登錄,如果想要重新登錄,請(qǐng)注銷(xiāo)后再嘗試!</td>
</tr>
</table></td>
</tr>
</table>
<%}%>
</form>
</body>
</html>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -