?? login.jsp
字號:
<%@ page language="java" contentType="text/html;charset=gb2312" import="wssd.*,java.sql.*"%>
<jsp:useBean id="db" class="wssd.connectDB" />
<jsp:useBean id="wb" class="wssd.wssdDB" />
<html>
<head>
<title>用戶登陸</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function go(para)
{
if(para == 1)
{
if(add_form.username.value.length == 0 || add_form.password.value.length == 0)
{
alert("不能為空");
}
else
{
add_form.submit();
}
}
if(para == 2)
{
add_form.reset();
}
}
</script>
</head>
<body>
<%
String name = request.getParameter("username");
String psw = request.getParameter("password");
if(name == null || name.length() == 0)
{
%>
<form name="add_form" action="login.jsp" method="post">
<table>
<tr>
<td class="text-login" align="right">用戶名:</td>
<td class="text-login"><input type="username" name="username" class="inputlength120"></td>
</tr>
<tr>
<td class="text-login" align="right">密碼:</td>
<td class="text-login"><input type="password" name="password" class="inputlength120"></td>
</tr>
<tr>
<td class="text-login"><input type="button" value="登陸" onclick="go(1)" class="logbutton"></td>
<td class="text-login"><input type="button" value="重填" onclick="go(2)" class="logbutton"></td>
</tr>
</table>
</form>
<%
}
else
{
int i = wb.checklogin(name,psw);
if(i != 0)
{
session.setAttribute("username",name);
session.setAttribute("user_id",String.valueOf(i));
shopping shoplist = new shopping();
shoplist.setShoplist();
session.setAttribute("shoplist",shoplist);
%>
<script language="javascript">
alert("登陸成功");
window.close();
opener.location.reload();
</script>
<%
}
else
{
session.removeAttribute("username");
session.removeAttribute("user_id");
session.removeAttribute("shoplist");
%>
<script language="javascript">
alert("登陸不成功");
window.close();
opener.location.reload();
</script>
<%
}
}
%>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -