@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        
        String url;
        request.setAttribute("active", "manageUsers");

        String firstName = request.getParameter("firstName");
        String lastName = request.getParameter("lastName");
        String username = request.getParameter("username");
        String password1 = request.getParameter("password1");
        String password2 = request.getParameter("password2");
        String email = request.getParameter("email");
        String userType = request.getParameter("userType");
        String status = request.getParameter("status");

        if(!firstName.isEmpty() && !lastName.isEmpty() &&
                !username.isEmpty() && !password1.isEmpty() &&
                !email.isEmpty()) {
            if(password1.equals(password2)) {
                try {
                    String encPassword = AeSimpleMD5.MD5(password1);

                    int success = UserDB.insert(firstName, lastName,
                            username, encPassword, userType, email,
                            status);

                    if(success==1)
                        request.setAttribute("successMessage", "User successfully created");
                    else
                        request.setAttribute("errorMessage", "Couldn't create merchant. Please try"
                            + "again later or contact support.");

                    //Retrieve all users from database
                    ArrayList<User> users = UserDB.getUsers();
                    request.setAttribute("users", users);

                } catch (Exception ex) {
                    Logger.getLogger(NewUserServlet.class.getName()).log(Level.SEVERE, null, ex);
                    request.setAttribute("errorMessage", "Couldn't create merchant. Please try "
                            + "again later or contact support. (Exception thrown)");
                }
                 url = "/manage/manageUsers.jsp";
            } else {
                request.setAttribute("firstName", firstName);
                request.setAttribute("lastName", lastName);
                request.setAttribute("username", firstName);
                request.setAttribute("email", email);
                request.setAttribute("errorMessage", "Passwords don't match");
                url = "/new/newUser.jsp";
            }
        } else {
            request.setAttribute("firstName", firstName);
            request.setAttribute("lastName", lastName);
            request.setAttribute("username", firstName);
            request.setAttribute("email", email);
            request.setAttribute("errorMessage", "Please fill all fields");
            url = "/new/newUser.jsp";
        }

        RequestDispatcher dispatcher =
                getServletContext().getRequestDispatcher(url);
        dispatcher.forward(request, response);
    }