@RequestMapping("/delete-appointment") public String deleteAppointment(int id, HttpSession session) throws Exception { if (session.getAttribute("username") == null) { throw new Exception("Not logged-in"); } Appointment appointment = appointments.findOne(id); appointments.delete(id); return "redirect:/"; }