String button;
button = request.getParameter("button");
if(button != null){
if(button.equals("Log medication")){
try{
AddLogForm form = formBeanFactory.create(request);
request.setAttribute("addlogform", form);
if(!form.isPresent()){
return "homepage.jsp";
}
HttpSession session = request.getSession(false);
//check the errors.
errors.addAll(form.getValidationErrors());
if (errors.size()!= 0) {
request.setAttribute("errors",errors);
medicationlist = medDAO.getMedicationList(user.getEmailAddress());
request.setAttribute("medicationlist", medicationlist);
return "logMed.jsp";