@Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    // For application Attributes
    ServletContext application = getServletContext();

    // Retrieve parameter "id"
    int id = Integer.parseInt(req.getParameter("id"));

    // Retrieve task from database
    EntityManager em = PersistenceUtils.createEntityManager();
    Task editTask = Task.findById(em, id);

    // Retrieve parameter "text"
    String text = req.getParameter("text");

    // Update Text
    editTask.setText(text);

    // Update task on database
    try {
      editTask.update(em);
    } catch (Exception e) {
      // TODO: Exception handling
    }
    em.close();

    // Redirect to index
    String base = (String) application.getAttribute("base");
    resp.sendRedirect(base + "/index");
  }
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    // Retrieve parameter "id"
    int id = Integer.parseInt(req.getParameter("id"));

    // Retrieve task from database
    EntityManager em = PersistenceUtils.createEntityManager();
    Task editTask = Task.findById(em, id);
    em.close();

    // Task as attribute
    req.setAttribute("task", editTask);

    // Forward to edit_form
    RequestDispatcher dispatcher = req.getRequestDispatcher("/views/edit_form.jsp");
    dispatcher.forward(req, resp);
  }