コード例 #1
0
  public void execute(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    HttpSession session = request.getSession(false);

    if (!session.isNew()) {
      String empId = request.getParameter("empId");
      String empIdOld = (String) session.getAttribute("empId");

      if (empIdOld != null && empId.equals(empIdOld)) count += 1;
    }

    EmployeeBean employeeBean = new EmployeeBean();
    mapToEmployeeBean(request, employeeBean);

    if ("success".equalsIgnoreCase(this.checkUser(employeeBean))) {

      String empId = request.getParameter("empId");
      session.setAttribute("empId", empId);
      String fileName =
          "/home/tsuser/Desktop/EmployeeAttendance/WebContent/Store"
              + employeeBean.getEmpId()
              + ".jpg";
      request.setAttribute("fileName", fileName);
      request.setAttribute("employeeBean", employeeBean);
      request.setAttribute("count", count);
      ServletContext context = request.getSession().getServletContext();
      context.getRequestDispatcher("/welcomeUser.jsp").forward(request, response);
    } else {
      ServletContext context = request.getSession().getServletContext();
      context.getRequestDispatcher("/login.jsp").forward(request, response);
    }
  }
コード例 #2
0
  private void mapToEmployeeBean(HttpServletRequest request, EmployeeBean empBean) {

    empBean.setEmpId(request.getParameter("empId"));
    empBean.setPassword(request.getParameter("password"));
  }