| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 555 人关注过本帖
标题:关于Servlet的小小问题.
取消只看楼主 加入收藏
楚小饭
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-10-22
结帖率:50%
收藏
已结贴  问题点数:35 回复次数:1 
关于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>&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;<%=vo.getIntro()%></td>
        </tr>
        <tr>
          <td height="25">&nbsp;&nbsp;&nbsp;&nbsp;企业宗旨:<%=vo.getTenet()%></td>
        </tr>
        <tr>
          <td height="30">&nbsp;&nbsp;&nbsp;&nbsp;企业文化: <%=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>&nbsp;</p>
    <p>&nbsp;</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 编辑 ]
搜索更多相关主题的帖子: Servlet 
2010-12-15 10:13
楚小饭
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-10-22
收藏
得分:0 
坐等高人
2010-12-15 10:19
快速回复:关于Servlet的小小问题.
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023561 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved