【JSP开源代码栏目提醒】:网学会员JSP开源代码为您提供voteAdminLogin.jsp参考,解决您在voteAdminLogin.jsp学习中工作中的难题,参考学习。
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.
sql.*" errorPage="" %>
<%@ include file="Connections/vote.jsp" %>
<%
// *** Validate request to log in to this site.
String MM_LoginAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) {
String queryString = request.getQueryString();
String tempStr = "";
for (int i=0; i < queryString.length(); i++) {
if (queryString.charAt(i) == '<') tempStr = tempStr + "<";
else if (queryString.charAt(i) == '>') tempStr = tempStr + ">";
else if (queryString.charAt(i) == '"') tempStr = tempStr + """;
else tempStr = tempStr + queryString.charAt(i);
}
MM_LoginAction += "?" + tempStr;
}
String MM_valUsername=request.getParameter("username");
if (MM_valUsername != null) {
String MM_fldUserAuthorization="";
String MM_redirectLoginSuccess="voteAdmin.jsp";
String MM_redirectLoginFailed="voteMain.jsp";
String MM_redirectLogin=MM_redirectLoginFailed;
Driver MM_driverUser = (Driver)Class.forName(MM_vote_DRIVER).newInstance();
Connection MM_connUser = DriverManager.getConnection(MM_vote_STRING,MM_vote_USERNAME,MM_vote_PASSWORD);
String MM_pSQL = "SELECT username, passwd";
if (!MM_fldUserAuthorization.equals("")) MM_pSQL += "," + MM_fldUserAuthorization;
MM_pSQL += " FROM vote.admin WHERE username=\'" + MM_valUsername.replace('\'', ' ') + "\' AND passwd=\'" + request.getParameter("passwd").toString().replace('\'', ' ') + "\'";
PreparedStatement MM_statementUser = MM_connUser.prepareStatement(MM_pSQL);
ResultSet MM_rsUser = MM_statementUser.executeQuery();
boolean MM_rsUser_isNotEmpty = MM_rsUser.next();
if (MM_rsUser_isNotEmpty) {
// username and password match - this is a valid user
session.putValue("MM_Username", MM_valUsername);
if (!MM_fldUserAuthorization.equals("")) {
session.putValue("MM_UserAuthorization", MM_rsUser.getString(MM_fldUserAuthorization).trim());
} else {
session.putValue("MM_UserAuthorization", "");
}
if ((request.getParameter("accessdenied") != null) && false) {
MM_redirectLoginSuccess = request.getParameter("accessdenied");
}
MM_redirectLogin=MM_redirectLoginSuccess;
}
MM_rsUser.close();
MM_connUser.close();
response.sendRedirect(response.encodeRedirectURL(MM_redirectLogin));
return;
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文件</title>
<style type="text/css">
<!--
.bluebox {
border: 1px solid #000099;
}
-->
</style>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> <form ACTION="<%=MM_LoginAction%>" name="form1" method="POST">
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="5"><img src="images/winxp_r1_c1.jpg" width="5" height="30"></td>
<td background="images/winxp_r1_c3.jpg"><font color="#FFFFFF" size="2"><img src="images/winxp_r1_c9.jpg" width="18" height="30" align="absmiddle">管理员登录画面</font></td>
<td width="28"><a href="digiBoard.asp"><img src="images/winxp_r1_c5.jpg" alt="离开登录画面" width="28" height="30" border="0"></a></td>
</tr>
</table>
<table width="300" border="0" align="center" cellpadding="4" cellspacing="2" class="bluebox">
<tr>
<td width="60"> <div align="right"><font size="2">账号</font></div></td>
<td><font size="2">
<input name="username" type="text" id="username" size="20">
</font></td>
</tr>
<tr>
<td width="60"> <div align="right"><font size="2">密码</font></div></td>
<td><font size="2">
<input name="passwd" type="pass
word" id="passwd" size="20">
</font></td>
</tr>
<tr>
<td colspan="2"> <div align="center"><font size="2"></font> <font size="2">
<input type="submit" name="Submit" value="登录管理界面">
<input type="button" name="Submit2" value="离开登录画面" onClick="window.location.href='voteMain.asp';">
</font></div></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>