@RequestMapping(
     value = "**/home",
     method = {RequestMethod.POST, RequestMethod.GET})
 public ModelAndView homePage(
     HttpServletRequest request, HttpServletResponse response, HttpSession session)
     throws SQLException {
   ModelAndView model = new ModelAndView();
   String role = (String) request.getSession().getAttribute("Role");
   String userName = (String) request.getSession().getAttribute("USERNAME");
   LoginHandler handler = new LoginHandler();
   ResultSet rs = handler.getEmail(userName);
   while (rs.next()) {
     role = rs.getString("usertype");
   }
   if (role.equalsIgnoreCase("USER")) {
     model.setViewName("customerhome");
   } else if (role.equalsIgnoreCase("MERCHANT")) {
     model.setViewName("merchanthome");
   }
   rs.close();
   return model;
 }
  @RequestMapping(
      value = {"/login/**/editPII**"},
      method = {RequestMethod.POST, RequestMethod.GET})
  public ModelAndView editPII(
      HttpServletRequest request, HttpServletResponse response, HttpSession session)
      throws IOException, SQLException {
    ModelAndView model = new ModelAndView();
    LoginHandler handler = new LoginHandler();

    String userName = (String) session.getAttribute("USERNAME");
    if (request.getParameter("submit") != null) {
      String changeColumn = request.getParameter("PII");
      String currentInfo = request.getParameter("curInfo");
      String newInfo = request.getParameter("newInfo");
      String confirmNewInfo = request.getParameter("cnfrmNewInfo");
      String otp = request.getParameter("otpCode");
      String otpString = (String) session.getAttribute("OTP");
      otpEnterTime =
          TimeUtility.generateSysDateMethod()
              + " "
              + TimeUtility.generateSysHoursMethod()
              + ":"
              + TimeUtility.generateSysMinutesMethod()
              + ":"
              + TimeUtility.generateSysSecondsMethod();
      //			long diff = System.currentTimeMillis() - startTime;
      int random = (new Random()).nextInt(900000) + 100000;
      //			int minutes = (int) ((diff / (1000*60)) % 60);
      long genSec = TimeUtility.getDifferenceinSeconds(modelTime, otpGenerateTime);
      long enterSec = TimeUtility.getDifferenceinSeconds(modelTime, otpEnterTime);
      if ((enterSec - genSec) > 180) {
        otpString = "";
      }
      if (currentInfo.isEmpty() || newInfo.isEmpty() || confirmNewInfo.isEmpty() || otp.isEmpty()) {
        model.addObject("emptyFields", "All fields are mandatory");
        model.setViewName("editPII");
      } else if (!otp.equalsIgnoreCase(otpString)) {
        model.addObject("wrongOtp", "Otp code does not match");
        model.setViewName("editPII");
      } else if (changeColumn.equalsIgnoreCase("Phone Number")) {
        Pattern pattern = Pattern.compile("\\d{10}");
        Matcher matcher1 = pattern.matcher(currentInfo);
        Matcher matcher2 = pattern.matcher(newInfo);

        if (matcher1.matches() && matcher2.matches()) {

          handler.personalInfoChange(userName, random, changeColumn, currentInfo, newInfo);
          model.setViewName("customerhome");
        } else {
          model.addObject(
              "phoneNum",
              "Valid phone number should be numeric, 10 digit and no special charaecters");
          model.setViewName("editPII");
        }
      } else {
        handler.personalInfoChange(userName, random, changeColumn, currentInfo, newInfo);
        model.setViewName("customerhome");
      }
    } else if (request.getParameter("otpButton") != null) {
      startTime = System.currentTimeMillis();
      otpGenerateTime =
          TimeUtility.generateSysDateMethod()
              + " "
              + TimeUtility.generateSysHoursMethod()
              + ":"
              + TimeUtility.generateSysMinutesMethod()
              + ":"
              + TimeUtility.generateSysSecondsMethod();
      OtpUtility otp = new OtpUtility();
      String email = null;
      ResultSet rs = handler.getEmail(userName);
      while (rs.next()) {
        email = rs.getString("email");
      }
      otp.sendOtp(request, email);
      model.setViewName("editPII");
    }
    return model;
  }