?? login.jsp
字號:
<%@ page language="java" import="java.util.*" import="java.sql.*"pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
</head>
<body bgcolor="99FFEE">
<P align=center>
<TABLE border=0>
<TBODY>
<TR>
<TD style="FILTER: Alpha(opacity=100,style=2)" width=420 background=http://xz.2000y.net/100007/uploadpic/200491119916461.gif height=296>
<P><B><EMBED align=right src=http://imgfree.21cn.com/free/flash/123.swf width=420 height=296 type=application/octet-stream wmode="transparent" quality="high"><EMBED pluginspage=http://www.macromedia.com/go/getflashplayer align=right src=http://imgfree.21cn.com/free/flash/16.swf width=420 height=296 type=application/x-shockwave-flash quality="high" wmode="transparent"></EMBED></B></P></TD></TR></TOBDY></TBODY></TABLE></P>
<form action="login.jsp" method="post">
<table width="244" bgcolor="pink"border="0" align="center">
<tr>
<td width="29" height="28"><div align="center">帳號</div></td>
<td width="210"><label>
<input name="account" type="text" id="account">
</label></td>
</tr>
<tr>
<td><div align="center">密碼</div></td>
<td><label>
<input name="password" type="text" id="password">
</label></td>
</tr>
<tr>
<td height="23" colspan="2"><label>
<div align="center">
<input type="submit" name="Submit" value="提交">
</div>
</label></td>
</tr>
</table>
</form>
<%
String account = request.getParameter("account")==null?"":request.getParameter("account");
String password = request.getParameter("password")==null?"":request.getParameter("password");
String ac=null;
Connection con = null;
//Statement st = null;
CallableStatement st=null;
ResultSet rs = null;
if(account!=null&&password!=null){
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=student", "sa", "");
String sql="{call exam(?)}";
st=con.prepareCall(sql);
st.setString(1,account);
rs = st.executeQuery();
while(rs.next()){
ac=rs.getString("password");
if(password.equals(ac)==true){
response.sendRedirect("Mainframe.jsp");
}
else {
%>
<center><table><tr><td>密碼錯誤或者用戶不存在!<td></tr></table><center>
<%
}
}
}catch (Exception e) {
out.print("數(shù)據(jù)庫操作出錯:" + e);
} finally {
if (rs != null)
rs.close();
if (st != null)
st.close();
if (con != null)
con.close();
}
}
if(account==""&&password==""){%>
<center><table><tr><td>請輸入帳號和密碼!<td></tr></table><center>
<%
}
%>
<center><table><tr><td>軟工3班maple ye-楓葉<td></tr></table><center>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -