@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String username = request.getParameter("username").trim();
        String password = request.getParameter("password").trim();
        if (Utils.isNullOrEmpty(username) || Utils.isNullOrEmpty(password)) {
            request.setAttribute("errorMessage", "Invalid username/password");
            request.getRequestDispatcher("index.jsp").forward(request, response);
            return;
        }
        UserDAO.User user = UserDAO.existsUser(username, password);
        if (user != null && user.isValid()) {
            HttpSession session = request.getSession();
            session.setAttribute("user", user);
            session.setAttribute("usertype", user.usertype);
            response.sendRedirect("app/home.jsp");
        } else {
            request.setAttribute("errorMessage", "Invalid username/password");
            request.getRequestDispatcher("index.jsp").forward(request, response);
        }        
    }