index.jsp
上传用户:sdtxjx
上传日期:2022-07-09
资源大小:2937k
文件大小:5k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=GBK" language="java" buffer="32kb"%>
  2. <%@ page import="javax.imageio.*"%>
  3. <%@ page import="dreamtime.dreamnews.*"%>
  4. <html>
  5. <head>
  6. <title>管理员登录</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=GBK">
  8.   
  9. <SCRIPT src="js/post.js"></SCRIPT> 
  10. <link href="css/bodystyle.css" rel="stylesheet" type="text/css">
  11. </head>
  12. <%
  13. response.setHeader("Pragma","No-cache");
  14. response.setHeader("Cache-Control","no-cache");
  15. response.setDateHeader("Expires", 0);
  16. request.setCharacterEncoding("GBK");      //设置编码方式为gb2312
  17. //处理表单,并进行异常处理
  18. String Action = request.getParameter("Action");
  19. if(Action!=null && Action.equals("Login"))
  20. {
  21. String Page1  = (String)request.getHeader("Referer"); //得到页面地址来源
  22. String Page2  = request.getRequestURL().toString(); //得到当前页面地址
  23. String methon = request.getMethod();
  24. if (methon.equals("POST") && Page2.equals(Page1))
  25. {
  26. try{
  27. Function Fun = new Function();
  28. Login login = new Login();
  29. String IP = request.getRemoteAddr(); //得到客户端Ip地址
  30. String User = request.getParameter("User");     //得到登录用户名
  31. String Pwd = request.getParameter("Pwd");       //得到登录密码
  32. String sCode = Fun.CheckReplace(request.getParameter("VerifyCode"));
  33. //if(!sCode.equals(session.getAttribute("VerifyCode")))
  34. //{
  35. //session.setAttribute("error","<li>验证码错误");
  36. //response.sendRedirect("index.jsp");
  37. //return;
  38. //}
  39. if (login.LoginCheck(User,Pwd,IP))
  40. {
  41. session.setAttribute("Login","Yes");
  42. session.setAttribute("AdminID",Integer.toString(login.AdminID));
  43. session.setAttribute("AdminType",Integer.toString(login.AdminType));
  44. session.setAttribute("AdminName",User);
  45. session.setAttribute("error","");
  46. out.println("<SCRIPT LANGUAGE='JavaScript'>alert('登录成功!');location.href='Admin_Main.jsp';</SCRIPT>");
  47. return;
  48. }
  49. else 
  50. {
  51. session.setAttribute("error","<li>用户名或密码错误");
  52. response.sendRedirect("index.jsp");
  53. return;
  54. }
  55. }catch(Exception e){
  56. response.sendRedirect("index.jsp");
  57. //out.println(e.getMessage());
  58. session.setAttribute("error","");
  59. return;
  60. }
  61. }
  62. else
  63. {
  64. response.sendError(403,"禁止访问");
  65. //out.print("出错" + Page1 + ";" + Page2);
  66. return;
  67. }
  68. }
  69. %>
  70. <body>
  71. <form name="form" action="index.jsp" method="POST" onSubmit="return LoginCheck()">
  72.   <p>&nbsp;</p>
  73.   <p>&nbsp;</p>
  74.   <table width="413" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#EEEAD6">
  75.     <tr>
  76.       <td height="29" colspan="3" background="images/topbg.gif">&nbsp;   </td>
  77.     </tr>
  78.     <tr>
  79.       <td width="3" background="images/link.gif"></td>
  80.       <td>
  81.   <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  82.           <tr>
  83.             <td height="75" background="images/topbg.gif">
  84. <table width="100%" height="75" border="0" cellpadding="0" cellspacing="0">
  85.           <tr>
  86.     <td width="30%" align="left" valign="bottom"><img src="images/xpbg.gif" width="411" height="74"></td>
  87.   </tr>
  88.   </table>
  89. </td>
  90.           </tr>
  91.           <tr>
  92.             <td>
  93. <table width="95%" border="0" align="center">
  94.       <tr>
  95.     <td>
  96.   <fieldset>
  97.                 <legend align="left" class="title" accesskey="F"><strong>登录窗口</strong></legend>
  98.                 <table width="100%" border="0" cellspacing="2" cellpadding="2">
  99.                 <tr> 
  100.   <td width="8%">&nbsp;</td>
  101.                         <td width="17%" class="chinese">用户名:</td>
  102.                   <td width="75%"><input name="User" type="text" class="chinese" id="User" style="font-size: 12px" size="16" maxlength="16">
  103.   </td>
  104.                 </tr>
  105.                 <tr> 
  106. <td width="8%">&nbsp;</td>
  107.                         <td width="17%" class="chinese">密 码:</td>
  108.                   <td><input name="Pwd" type="password" class="chinese" id="Pwd" style="font-size: 12px" size="16" maxlength="16">
  109.                   </td>
  110.                 </tr>
  111.     <tr>
  112.   <td width="8%">&nbsp;</td>
  113.                         <td class="chinese">验证码:</td>
  114.                         <td><input name="VerifyCode" type="text" class="chinese" id="VerifyCode" style="font-size: 12px" size="6" maxlength="6"> 
  115.                           <span class="info1">&nbsp;<img src="VerifyCode.jsp">
  116.                         (区分大小写)</span></td>
  117.                 </tr>
  118.                 <tr>
  119.                   <td colspan="3" align="center"><div class="info1">
  120.   <%=((String)session.getAttribute("error")==null)? "" : (String)session.getAttribute("error")%></div></td>
  121.                 </tr>
  122.                 <tr> 
  123.                   <td colspan="3" align="center" height="30"><input type="submit" name="submit" value=" 登 录 " class="button"> 
  124.                     <input name="Action" type="hidden" id="Action" value="Login">
  125.                     <input type="reset" name="submit2" value=" 清 除 " class="button"></td></tr>
  126.               </table>
  127.   </fieldset> 
  128.   &nbsp;</td></tr>
  129.   </table></td>
  130.           </tr>
  131.         </table></td>
  132.       <td width="3" background="images/link.gif"></td>
  133.     </tr>
  134. <tr><td height="3" background="images/linkbom.gif" colspan="3"></td></tr>
  135. </table>
  136.   <p>&nbsp;</p>
  137.   <p>&nbsp;</p>
  138. </form>
  139. </body>
  140. </html>