关于Servlet的小小问题.
登录页面 index.jsp 登录成功后显示 login.jsp,指向是没有问题,
但是登陆上去后会有1秒钟的时间显示login.jsp,之后系统就会认定连接失效,转向connectionFail.jsp
我没有看到任何判断连接断开的代码,都不知道系统怎么判断的.
各位帮帮忙看看.
Servlet 代码
程序代码:
// 验证用户登录 public void checkManager(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { boolean flag = true; session = request.getSession(); ManagerList manager = ManagerList.getInstance(); Vector vo = manager.getList(); EmployeeVO employeevo = dao.employeeCheck(request .getParameter("account")); if (!vo.isEmpty() && vo != null) { Enumeration en = vo.elements(); while (en.hasMoreElements()) { EmployeeVO em = (EmployeeVO) en.nextElement(); if (em.getEm_accouts().equals(request.getParameter("account"))) { flag = false; } } } else { flag = true; } /*----------------------以上代码判断员工是否在线----------------------------------------*/ if(employeevo.getEm_accouts()==null){ request.setAttribute("error", "您输入的帐号和密码不存在!!!"); }else if (!employeevo.getEm_password().equals(request.getParameter("password"))){ request.setAttribute("error", "您输入的密码不正确"); }else if (!flag){ request.setAttribute("erorr", "该员工已经登录!!!"); }else{ int id = employeevo.getEm_id().intValue(); ManagerTrace managerTrace = new ManagerTrace(); managerTrace.setId(id); manager.addManager(employeevo); session.setAttribute("managerTrace", managerTrace); session.setAttribute("id", String.valueOf(id)); request.setAttribute("employee", employeevo); request.setAttribute("number", employeevo.getEm_number()); request.setAttribute("right", this.dao.getRight(employeevo.getEm_number())); request.setAttribute("manager", dao.managerSelect(employeevo.getEm_number())); } RequestDispatcher requestDispatcher=request.getRequestDispatcher("employee/emLand.jsp"); requestDispatcher.forward(request, response); }emLand.jsp
程序代码:
<%@ page contentType="text/html; charset=gb2312" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <link href="css/style.css" rel="stylesheet" type="text/css"> <title>员工登录处理</title> </head> <body> <div align="center"> <p> </p> <b> <%if(request.getAttribute("erorr")==null){%> <% session.setAttribute("employee",request.getAttribute("employee")); session.setAttribute("right",request.getAttribute("right")); session.setAttribute("number",request.getAttribute("number")); session.setAttribute("manager",request.getAttribute("manager")); //session.setMaxInactiveInterval(60); %> <meta http-equiv="refresh" content="0;URL=login.jsp"> <%}else{%> <strong> <%=request.getAttribute("erorr")%></strong> <meta http-equiv="refresh" content="3;URL=index.jsp"> <%}%> </b> </div> </body> </html>login.jsp
程序代码:
<table width="80%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bordercolordark="#819BBC" bordercolorlight="#FFFFFF""> <tr align="left" valign="top"> <td height="21" colspan="3"><jsp:include page="top.jsp"/></td> </tr> <tr> <td height="80%" background="picture/back.jpg" scope="row"><div align="center" class="style1">公司简介 </div> <table width="63%" height="202" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="147"> <%=vo.getIntro()%></td> </tr> <tr> <td height="25"> 企业宗旨:<%=vo.getTenet()%></td> </tr> <tr> <td height="30"> 企业文化: <%=vo.getCulture()%> </td> </tr> </table> <table width="63%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="52%" height="30">公司电话:<%=vo.getTel()%></td> <td width="48%" >公司传真:<%=vo.getFax()%></td> </tr> <tr> <td height="30">公司地址:<%=vo.getAddress()%></td> <td >联 系 人:<%=vo.getManager()%></td> </tr> </table> <p> </p> <p> </p></td> </tr> </table>connectFail.jsp
程序代码:
<%@ page contentType="text/html; charset=gb2312" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>判断用户是否为空</title> </head> <body> <div align="center"><strong>员工连接已经断开,请重新登录 !!! </strong></div> <meta http-equiv="refresh" content="3;URL=index.jsp"> </body> </html>
[ 本帖最后由 楚小饭 于 2010-12-15 10:17 编辑 ]