Source:
public String editProfileSubmit( @RequestParam(value = "name", required = false) String name, @RequestParam(value = "password", required = false) String password, @RequestParam(value = "sex", required = false) String sex, @RequestParam(value = "height", required = false) Integer height, @RequestParam(value = "weight", required = false) Integer weight, Model model, HttpSession session) { MemberDao memberDao = new MemberDao(); Member member = (Member) session.getAttribute("member"); Set<Team> teams = member.getTeams(); model.addAttribute("teams", teams); TournamentDao tournamentDao = new TournamentDao(); List<Tournament> tournaments = tournamentDao.getLastXTournaments(5); model.addAttribute("tournaments", tournaments); String errorMessage = ""; if (name != null && name.length() != 0) { if (name.length() <= 45) { member.setName(name); } else { errorMessage = errorMessage + " " + NAME_ERROR_MESSAGE; } } if (password != null && password.length() != 0) { if (password.length() <= 45) { String genPassword = StringUtils.secureString(password); member.setPassword(genPassword); } else { errorMessage = errorMessage + " " + PASSWORD_ERROR_MESSAGE; } } if (sex != null) { if (sex.equals("m") || sex.equals("f")) { member.setSex(sex); } else { errorMessage = errorMessage + " " + SEX_ERROR_MESSAGE; } } if (height != null) { if (height >= 0 && height <= 100) { member.setHeight(height); } else { errorMessage = errorMessage + " " + HEIGHT_ERROR_MESSAGE; } } if (weight != null) { if (weight >= 0 && weight <= 1000) { member.setWeight(weight); } else { errorMessage = errorMessage + " " + WEIGHT_ERROR_MESSAGE; } } memberDao.save(member); if (!errorMessage.equals("")) { System.out.println(errorMessage); model.addAttribute("errorMessage", errorMessage); } else { model.addAttribute("message", "Profile updated."); } session.setAttribute("member", member); return "profile"; }

Target:
public String editProfileSubmit( @RequestParam(value = "name", required = false) String name, @RequestParam(value = "password", required = false) String password, @RequestParam(value = "sex", required = false) String sex, @RequestParam(value = "height", required = false) Integer height, @RequestParam(value = "weight", required = false) Integer weight, Model model, HttpSession session) { MemberDao memberDao = new MemberDao(); Member member = (Member) session.getAttribute("member"); Set<Team> teams = member.getTeams(); model.addAttribute("teams", teams); TournamentDao tournamentDao = new TournamentDao(); List<Tournament> tournaments = tournamentDao.getLastXTournaments(5); model.addAttribute("tournaments", tournaments); String errorMessage = ""; if (name != null && name.length() != 0) { if (name.length() <= 45) { member.setName(name); } else { errorMessage = errorMessage + " " + NAME_ERROR_MESSAGE; } } if (password != null && password.length() != 0) { if (password.length() <= 45) { String genPassword = StringUtils.secureString(password); member.setPassword(genPassword); } else { errorMessage = errorMessage + " " + PASSWORD_ERROR_MESSAGE; } } if (sex != null) { if (sex.equals("m") || sex.equals("f")) { member.setSex(sex); } else { errorMessage = errorMessage + " " + SEX_ERROR_MESSAGE; } } if (height != null) { if (height >= 0 && height <= 100) { member.setHeight(height); } else { errorMessage = errorMessage + " " + HEIGHT_ERROR_MESSAGE; } } if (weight != null) { if (weight >= 0 && weight <= 1000) { member.setWeight(weight); } else { errorMessage = errorMessage + " " + WEIGHT_ERROR_MESSAGE; } } memberDao.save(member); if (!errorMessage.equals("")) { System.out.println(errorMessage); model.addAttribute("errorMessage", errorMessage); } else { model.addAttribute("message", "Profile updated."); } session.setAttribute("member", memberDao.getMemberById(member.getId())); return "profile"; }