?? login.jsp
字號:
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<%
try{
String Username=new String(request.getParameter("username").getBytes("iso-8859-1"),"gbk");
String Password=request.getParameter("password");
String input= request.getParameter("rand");
if (Username!=null && Password!=null)
{
//把用戶名和密碼保存在session中
session.setAttribute("user_name",Username);
session.setAttribute("pass_word",Password);
session.setAttribute("input",input);
//驗證用戶輸入的驗證碼是否正確
if(input.equals(session.getAttribute("random")))
{
//如果正確就跳轉到check.jsp驗證用戶名密碼
response.sendRedirect("check.jsp");
}
else
{
//驗證碼不正確
out.println("<font color='red'>驗證碼錯誤,系統3秒后會自動轉到登錄頁面 </font>");
response.setHeader("refresh","3;URL=login.jsp" );
// JOptionPane.showMessageDialog(null,"請選擇文件!","提示",JOptionPane.ERROR_MESSAGE);
}
}}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();}
%>
<html>
<head>
<script type="text/javascript">
function check()
{
if (form.username.value=="")
{
alert("請輸入用戶名!!!");
form.username.focus();
return false;
}
if (form.password.value=="")
{
alert("請輸入密碼!!!");
form.password.focus();
return false;
}
if (form.rand.value=="")
{
alert("請輸入驗證碼!!!");
form.rand.focus();
return false;
}
}
</script>
<title>登錄</title>
</head>
<link type="text/css" rel="stylesheet" href="style.css">
<body>
<center>
<table>
<tr>
<td width="690" height="250">
<img src="images/tianzhao.jpg" />
</td>
</tr>
<tr>
<td align="center" height="221">
<form name="form" onSubmit="return check()"
action="login.jsp"
method="post">
<table border="0">
<tr>
<td colspan="2" align="center" class="t7">
醫藥公司管理系統登錄
</td>
</tr>
<tr>
<td class="t1">
用戶名:
</td>
<td>
<input type="text" id=username name="username" class="button">
</td>
</tr>
<tr>
<td class="t1">
密 碼:
</td>
<td>
<input type="password" id=password name="password" class="button">
</td>
<tr>
<td height="54" align="center">認證碼:</td>
<td width="181" height=54>
<input type=text id=rand name=rand maxlength=4 value="" size=6>
<img border=1 src="image.jsp">
</td>
</tr>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value=" 登錄 ">
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td bgcolor="#E3E3E3" height="80" align="center" class="t1">
制作: 05 本(1) 范春曉 學號:2005081127
</td>
</tr>
</table>
</center>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -