3.权限控制:登陆页面(注意javascript第一句话)

来源:互联网 发布:台湾自由行 知乎 编辑:程序博客网 时间:2024/06/06 07:03
<%@ page language="java" contentType="text/html; charset=GB18030"    pageEncoding="GB18030"%><%@ page import="com.bjpowernode.drp.sysmgr.domain.*" %>    <%@ page import="com.bjpowernode.drp.sysmgr.manager.*" %>    <%String command = request.getParameter("command");if ("login".equals(command)) {// 用户填写的用户名String userId = request.getParameter("userId");// 用户填写的密码String password = request.getParameter("password");// 用户填写的验证码String authCodeWriteByUser = request.getParameter("authCode");// 正确的验证码String authCode = (String)session.getAttribute("rand");// 如果验证码填写正确,才进行用户名和密码的验证,否则,直接提示验证码填写错误 if(!authCodeWriteByUser.equalsIgnoreCase(authCode)) {out.println("验证码错误!");} else {// 用户名和密码的验证try {User user = UserManager.getInstance().login(userId, password); //将用户信息设置到session中session.setAttribute("user_info", user);//设置session超时//session.setMaxInactiveInterval(60*60);//重定向到主控页面response.sendRedirect(request.getContextPath() + "/main.jsp");}catch(UserNotFoundException e) {out.println(e.getMessage());}catch(PasswordNotCorrentException e) {out.println(e.getMessage());}}/*//演示SQL注入----beginboolean success = UserManager.getInstance().login(userId, password);if (success) {response.sendRedirect(request.getContextPath() + "/main.jsp");}//演示SQL注入----end*/}%><HTML><head><meta http-equiv="Content-Type" content="text/html; charset=GB18030"><TITLE></TITLE><script src="script/client_validate.js"></script><SCRIPT language=JavaScript>// 如果当前帧(登陆页面所在的帧)不在最高层,就让当前帧处于最高帧if (window.self != window.top) {window.top.location = window.self.location;}function init(){loginForm.userId.focus();}function submitForm(){if (trim(loginForm.userId.value).length == 0) {alert("用户代码不能为空!");loginForm.userId.focus();return;}if (trim(loginForm.password.value).length == 0) {alert("密码不能为空!");   loginForm.password.focus();return;}loginForm.action = "login.jsp";loginForm.method = "post";loginForm.submit();}/** * 单击“看不清楚?换一张”,src重新访问servlet(返回另一张图片) */function changeAnother() {// 验证码图片var authImage = window.document.getElementById("authImage");// src重新访问servlet(返回另一张图片),command=Date(),Date()返回一个精确到秒的时间,每次访问都不一样,访问浏览器找缓存 authImage.src = "${pageContext.request.contextPath}/servlet/AuthImageServlet?comand=" + Date();}</SCRIPT></HEAD><BODY leftMargin=0 topMargin=0 onload=init()><FORM name="loginForm" action="main.html" method=post><input type="hidden" name="command" value="login"><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR height=50><TD width=1 background="images/logobar_left.gif"><IMG height=50 src="images/spacer.gif" width=1 border=0></TD><TD width="416" align=left vAlign=centerbackground="images/logobar_mid.gif"><em><strong><font color="#FFFFFF" size="+3"face="宋体"><IMG height=1 src="images/spacer.gif" width=5border=0>DRP分销管理系统</font> </strong> </em></TD><TD width="478" align=right vAlign=centerbackground="images/logobar_mid.gif"><div align="right"><a href="#"><IMG height=25src="images/banner_help_button.gif" width=60 border=0name=banner_help_button> </a><IMG height=1 src="images/spacer.gif" width=5 border=0></div></TD></TR></TBODY></TABLE><TABLE height="80%" cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR><!-- The login dialog --><TD vAlign=center align=middle width="100%"><!-- login dialog --><TABLE cellSpacing=0 cellPadding=0 border=0><!-- title bar --><TBODY><TR><!-- this row is kind of a dummy row to set the column widths for the whole page--><TD width=8><IMG height=1 src="images/spacer.gif" width=8 border=0></TD><!-- left edge --><TD width=15><IMG height=1 src="images/spacer.gif" width=15 border=0></TD><!-- title image/left margin --><TD width=200><IMG height=1 src="images/spacer.gif" width=200 border=0></TD><!-- main area --><TD width=14><IMG height=1 src="images/spacer.gif" width=14 border=0></TD><!-- right margin --><TD width=11><IMG height=1 src="images/spacer.gif" width=11 border=0></TD><!-- right edge --></TR><TR><TD width=8><IMG height=9 src="images/top_left.gif" width=8 border=0></TD><TD background="images/top.gif" colSpan=3><IMG height=9 src="images/spacer.gif" width=1 border=0></TD><TD width=11><IMG height=9 src="images/top_right.gif" width=11 border=0></TD></TR><TR><TD width=8 background="images/left.gif"><IMG height=15 src="images/spacer.gif" width=8 border=0></TD><TD align=left width=140 bgColor=#000033 colSpan=3><FONT face="verdana, arial, helvetica, sans-serif"color=#ffffff size=-1> <B>登录DRP</B> </FONT></TD><TD width=11 background="images/right.gif"><IMG height=15 src="images/spacer.gif" width=11 border=0></TD></TR><TR><TD width=8><IMG height=9 src="images/middle_left.gif" width=8 border=0></TD><TD background="images/top.gif" colSpan=3><IMG height=9 src="images/spacer.gif" width=1 border=0></TD><TD width=11><IMG height=9 src="images/middleRight.gif" width=11 border=0></TD></TR><TR bgColor=white><TD width=8 background="images/left.gif"><IMG height=1 src="images/spacer.gif" width=8 border=0></TD><TD></TD><TD><TABLE cellSpacing=5 cellPadding=0 align=centerbackground="images/login1x1.gif" border=0 valign="middle"><TBODY><TR><TD><BR></TD></TR><TR><TD align=left><FONT face="verdana, arial, helvetica, sans-serif"size=-1>用户名: </FONT></TD><TD align=left><INPUT name="userId" type="text" size="20" maxlength="20"></TD></TR><TR><TD align=left><FONT face="verdana, arial, helvetica, sans-serif"size=-1>密   码:</FONT></TD><TD align=left><INPUT name="password" type="password" size="21"maxlength="20"></TD></TR><TR><TD align=left><FONT face="verdana, arial, helvetica, sans-serif"size=-1>验证码:</FONT></TD><TD align=left><INPUT name="authCode" id="authCode" type="text" size="6" maxlength="6"> <img id="authImage" name="authIamge" src="${pageContext.request.contextPath}/servlet/AuthImageServlet"><%-- 单击“看不清楚?换一张”,src重新访问servlet(返回另一张图片) --%><span onclick="changeAnother()" style="cursor:hand"><font style="font-size: 10px; color: blue">看不清楚?换一张</font></span></TD></TR><TR><TD><BR></TD></TR></TBODY></TABLE></TD><TD></TD><TD width=8 background="images/right.gif"><IMG height=1 src="images/spacer.gif" width=8 border=0></TD></TR><!-- end of inner main area, right side --><!-- inner button bar --><TR><TD width=8><IMG height=6 src="images/command_top_left.gif" width=8border=0></TD><TD background="images/command_top.gif" colSpan=3><IMG height=6 src="images/spacer.gif" border=0></TD><TD width=11><IMG height=6 src="images/command_top_right.gif" width=11border=0></TD></TR><TR bgColor=#cccccc><TD width=8><IMG height=20 src="images/command_mid_left.gif" width=8border=0></TD><TD><BR></TD><!-- command buttons --><TD align=right colSpan=2><TABLE cellSpacing=0 cellPadding=0 border=0><TBODY><TR><TD><A href="javascript:submitForm()" onc><IMG height=20src="images/login_button.gif" width=71 border=0name=button> </A></TD></TR></TBODY></TABLE></TD><TD width=11><IMG height=20 src="images/command_mid_right.gif" width=11border=0></TD></TR><TR><TD width=8><IMG height=8 src="images/command_bottom_left.gif" width=8border=0></TD><TD background="images/command_bottom.gif" colSpan=3><IMG height=8 src="images/spacer.gif" width=1 border=0></TD><TD width=11><IMG height=8 src="images/command_bottom_right.gif" width=11border=0></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><CENTER></CENTER></FORM><SCRIPT language=JavaScript></SCRIPT></BODY></HTML>


原创粉丝点击