📄 login.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" %><%@ include file="../include/config.jsp" %><%@ include file="../include/global.jsp" %><%@ include file="../include/dbUtil.jsp" %><%@ include file="../include/dbConnect.jsp" %><%! int ni=-1;%><%boolean isDebug=isDebug(request,false);if(isDebug){ out.println("Now it's in DEBUG mode, and the time is "+getDateAndTime(null)+" !<br>"); Enumeration enm=session.getAttributeNames(); Object linStr=null; while(enm.hasMoreElements()){ linStr=enm.nextElement(); out.println(linStr+" = "); out.println(session.getAttribute(linStr.toString())+"<br>"); }}DBConnect dbCon=new DBConnect(dbString,dbClass,dbUser,dbPswd);try{ String pageHint=null; String action=request.getMethod(); String toURL=request.getParameter("toURL"); String userID = request.getParameter("userID"); String userPswd=request.getParameter("userPswd"); if(session.getAttribute("hashtable")!=null&&isDebug){ Hashtable ht=(Hashtable)session.getAttribute("hashtable"); out.println("theID=*"+ht.get("theID")+"*<br>"); } if(action.equalsIgnoreCase("POST")&&userID!=null&&userPswd!=null){ String strSQL="select usr_pswd,usr_nick,usr_name,usr_class,usr_email from web_users where usr_nick='"+userID.toLowerCase()+"'"; if(isDebug)out.println(strSQL); String[] userInfo=getValues(dbCon,strSQL); if(userInfo!=null&&userInfo[0].equals(userPswd)){ session.removeAttribute("loadCounter"); MySession mySession=new MySession(userInfo[1],userInfo[2],userInfo[3],userInfo[4]); session.setAttribute("mySession",mySession); if(toURL!=null)response.sendRedirect(toURL); else alertPage(response,8000,null); } else{ Object obj=session.getAttribute("loadCounter"); int counter=0; if(obj!=null){ counter=Integer.parseInt((String)obj); } counter++; if(counter<5){ session.setAttribute("loadCounter",String.valueOf(counter)); pageHint="对不起,你的用户名或者密码有误!你还有 "+(5-counter)+" 次机会尝试登陆。"; } else{ alertPage(response,7000,null); session.removeAttribute("hashtable"); } } } else{ String doing=request.getParameter("doing"); if(doing!=null&&doing.equalsIgnoreCase("logout")){ session.removeAttribute("mySession"); alertPage(response,8000,null); } //out.println("doing="+doing); pageHint="请登陆Ofcool.com!"; session.setAttribute("loadCounter","0"); }%><script language="JavaScript"> function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; } } else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); } MM_reloadPage(true); function sub() { if (form1.userID.value == "") { alert("请选输入用户名!"); form1.userID.focus(); return false; } if (form1.userPswd.value == "") { alert("请选输入密码!"); form1.userPswd.focus(); return false; } form1.submit(); }</script><style type="text/css"></style><%@ include file="../include/header.jsp" %><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="50" align=center><%=pageHint%></td> </tr> <tr> <td align="center"> <!-- 登录表单 --> <form name="form1" action="<%=request.getRequestURI()%>" method="post" onkeydown='javascript:if(window.event.keyCode==13){sub()}'> <input type=hidden name=toURL value="<%=toURL%>"> <table width="60%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><font color="#000000"><b>用户名:</b> <input type="text" name="userID" class="formedit" > </font></td> <td><font color="#000000"><b>密码:</b> <input type="password" name="userPswd" class="formedit" > </font></td> <td> <input type="button" value="登录" class="formsub2" onclick='javascript:sub()'> </td> </tr> </table> </form> <!-- 登录表单 --> </td> </tr></table><script>form1.userID.focus();</script><%@ include file="../include/footer.jsp" %><%}catch(Exception e){alertPage(response,7775,e.toString());}finally{dbCon.close();}%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -