/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
    response.setContentType("text/html");
    HttpSession session = request.getSession(true);
    AuthenticationModel authenticationModel =
        (AuthenticationModel) session.getAttribute("authenticationModel");
    ResetPasswordDTO resetPasswordDTO = new ResetPasswordDTO();
    resetPasswordDTO.setPassword(request.getParameter("password"));
    resetPasswordDTO.setConfirmPassword(request.getParameter("confirmPassword"));

    /*
     * This method is to verify your confirm password and password are same or not.
     */

    resetPasswordDTO.setConfirmPassword(request.getParameter("confirmPassword"));
    if (resetPasswordDTO.getPassword() != null
        && resetPasswordDTO.getConfirmPassword() != null
        && resetPasswordDTO.getPassword().equals(resetPasswordDTO.getConfirmPassword())) {
      AuthenticationBusiness encryptPassword = new AuthenticationBusiness();
      authenticationModel.setPassword(resetPasswordDTO.getPassword());
      authenticationModel = encryptPassword.encryptPassword(authenticationModel);
      AuthenticationInterface resetPassword = new AuthenticationDataLayer();

      /*
       * Updating the password in the database.
       */
      resetPassword.resetPassword(authenticationModel);
      request.setAttribute("MessageRP", "Your Password reset successfull.");
      RequestDispatcher dispatcher = request.getRequestDispatcher("index.jsp");
      dispatcher.forward(request, response);
    } else {
      /*
       * If password and confirm password are not same then redirects to the same page with error message.
       */
      request.setAttribute("errorMessageRP", "Entered password and confirmPassword are not same.");
      RequestDispatcher dispatcher = request.getRequestDispatcher("resetPassword.jsp");
      dispatcher.forward(request, response);
    }
  }
 @Override
 public StudentModel getDOB(AuthenticationModel authenticationModel) {
   // TODO Auto-generated method stub
   StudentModel studentModel = new StudentModel();
   studentModel.setStudentEmailID(authenticationModel.getUserName());
   ResultSet myRes = null;
   try {
     Class.forName("com.mysql.jdbc.Driver");
     Connection myCon =
         DriverManager.getConnection("jdbc:mysql://localhost:3306/EnrollTrackDB", "root", "");
     Statement myStmt = myCon.createStatement();
     myRes =
         myStmt.executeQuery(
             "SELECT `studentDOB` from studentInformation where studentEmail='"
                 + studentModel.getStudentEmailID()
                 + "'");
     while (myRes.next()) {
       studentModel.setDOB(myRes.getString("studentDOB"));
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return studentModel;
 }