@Override
    public void checkedDoPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {

        if (isLoggedIn(req.getSession()))
            forceLogOut(req, resp);

        String userName = req.getParameter("username");
        String name = req.getParameter("name");
        // String name = "Jisan Mahmud";
        String password = req.getParameter("password");
        String password2 = req.getParameter("password2");
        String email = req.getParameter("email");
        Date dob = parseDateString(req.getParameter("dob"));
        String sex = req.getParameter("sex");

        if (email != null)
            email = email.toLowerCase();

        if (!UserModel.userNameAvailable(userName)) {
            SimpleFeedbackPageLoader
                    .showSimpleFeedbackPage(
                            req,
                            resp,
                            "Error",
                            "Username unavailable",
                            "Sorry. This username is already taken or invalid. Please choose something else");

        } else if (!passwordIsInCorrectFormat(password)) {

            SimpleFeedbackPageLoader
                    .showSimpleFeedbackPage(req, resp, "Error",
                            "Password too short",
                            "Password too short. Please choose a password of at least length 5");

        } else if (!passwordsMatch(password, password2)) {
            SimpleFeedbackPageLoader.showSimpleFeedbackPage(req, resp, "Error",
                    "Password mismatch",
                    "Passwords didn't match. Feel up again");
        } else if (!UserModel.emailAvailableForNewUser(email)) {

            SimpleFeedbackPageLoader.showSimpleFeedbackPage(req, resp, "Error",
                    "Email already used",
                    "This email is invalid or have already been used");
        } else if (!dateOfBirthIsValid(dob)) {

            SimpleFeedbackPageLoader.showSimpleFeedbackPage(req, resp, "Error",
                    "Invalid date of birth",
                    "Date of birth year should be between 1900 and 2006");
        } else {

            try {
                if (UserModel.createNewUser(userName, name, password, dob, sex,
                        email)) {
                    SimpleFeedbackPageLoader
                            .showSimpleFeedbackPage(req, resp,
                                    "Account created", "Account created",
                                    "Your account has been created. Please log in to continue");
                } else
                    throw new SQLException();
            } catch (SQLException ex) {
                SimpleFeedbackPageLoader
                        .showSimpleFeedbackPage(req, resp, "Error",
                                "Account creation failed",
                                "Sorry. Your account could not be created. Please try again later.");
            }

        }
    }