📄 login.jsp
字号:
<%@ page errorPage="ErrPage.jsp"
import="java.util.Date, java.sql.*"
contentType="text/html;charset=gb2312"%>
<jsp:useBean id="pool" scope="application" class="com.PoolBean"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>系统登录</title>
<style type="text/css">
.submitstyle {
BACKGROUND-COLOR: #33ccff;
BORDER-BOTTOM: #665b8e 1px solid;
BORDER-LEFT: #ffffff 1px solid;
BORDER-RIGHT: #665b8e 1px solid;
BORDER-TOP: #ffffff 1px solid;
COLOR: #000080;
PADDING-TOP: 1px;
font : bold 14pt;
}
.input {
color:#000080;
border-style:outset;
border-width:0;
FONT-SIZE: 16pt;
BORDER-BOTTOM: 1px solid;
BACKGROUND-COLOR: #33ccff;
}
</style>
</head>
<script language="JavaScript" type="text/Javascript">
function dataCheck()
{
if (this.LoginForm.username.value == "")
{
window.alert("对不起,您必须输入用户名!");
this.LoginForm.username.focus();
return;
}
if (this.LoginForm.pwd.value == "")
{
window.alert("对不起,您必须输入口令!");
this.LoginForm.pwd.focus();
return;
}
LoginForm.submit();
}
function myReset()
{
this.LoginForm.reset();
LoginForm.username.focus();
}
function onClick()
{
this.location.replace("register.jsp");
}
</script>
<body bgproperties="fixed" bgcolor="#00a6e2">
<%
try
{
String strUser = ""; //用户输入的用户名
String strPWD = ""; //用户输入的口令
String strMsg = ""; //
session.setAttribute("LoginUser", "");//注销
strUser = request.getParameter("username"); //获取用户输入的用户名
strPWD = request.getParameter("pwd"); //获取用户输入的口令
if (strUser != null && strPWD != null && !strUser.equals("") && !strPWD.equals(""))
{
strUser.trim();
strPWD.trim();
strUser = new String(strUser.getBytes("8859_1"));
// com.PoolBean pool = new com.PoolBean();
if (pool.getConnectionSize() == 0)
pool.initializePool();
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
con = pool.getConnection();
stmt = con.createStatement();
String strSQL ="SELECT code, name, password FROM user WHERE code ='"+strUser+"' AND password ='"+strPWD+"'";
rs = stmt.executeQuery(strSQL);
if (!rs.next()) //登录失败
{
strMsg = "您输入的用户名或密码不正确,请重新输入!";
%>
<script language="JavaScript" type="text/Javascript">
<!--
alert("<%=strMsg%>");
// end hiding contents -->
</script>
<%
if (rs != null) rs.close();
pool.releaseConnection(con);
}
else //登录成功
{
if (rs != null) rs.close();
pool.releaseConnection(con);
session.setAttribute("LoginUser",strUser);
response.sendRedirect("default.jsp"); //进入系统主页面
}
}
}
catch(Exception e)
{
System.out.println("Exception: " + e.getMessage());
}
%>
<div align=center>
<p> </p>
<p> </p>
<p align=center><font face="隶书" size="20pt">会务管理系统</font></P>
<p> </p>
<form method=post name=LoginForm action="Login.jsp">
<table border=0 cellspacing=3 style="FONT-WEIGHT: bold; FONT-SIZE: 14pt;
COLOR: #000080; BORDER-COLLAPSE: collapse" bordercolor=#111111
width=267 bgcolor=#33ccff>
<tr>
<td align=middle colspan=2
style="BORDER-BOTTOM: #0000cc 2px solid">用户登录
</td>
</tr>
<tr align=middle>
<td width=121 bgColor=#3399ff> 用户名:</TD>
<td width=120>
<input name=username size=10 class="input">
</td>
</tr>
<tr align=middle>
<td width=121 bgColor=#3399ff> 密 码:</TD>
<td>
<input name=pwd size=10 type=password class="input">
</TD></TR>
</table>
<table>
<tr>
<td class="submitstyle" onClick="dataCheck()">
登 录
</td>
<td class="submitstyle"onClick="myReset()">
重 填
</td>
<td class="submitstyle"onClick="onClick()">
注 册
</td>
</tr>
</table>
</form>
</div>
<div align=center>
<br>
<table align=center border=0 cellspacing=1
style="FONT-WEIGHT: bold; COLOR: #000080">
<tr align=center>
<td></TD></TR>
<tr align=center>
<td></TD></TR>
<tr align=center>
<td></TD></TR>
<tr>
<td align=middle>湖南长沙大学</TD></TR>
<TR><td align=middle>版权所有 2002年</td></TR>
</TABLE>
</DIV>
<Script language=JavaScript type="text/Javascript">
LoginForm.username.focus();
</Script>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -