public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { String name = req.getParameter("name"); String labels = req.getParameter("labels"); if (name != null) { name = name.trim(); if (!name.isEmpty()) { TaskRepository repository = new TaskRepository(); try { repository.addTaskWithLabels(name, labels); } finally { repository.close(); } } } resp.sendRedirect("/list/"); }
public void close() { repository.close(); }