/**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    JSONObject result = new JSONObject();
    PrintWriter out = response.getWriter();

    try {
      try {
        response.setContentType("text/html;charset=UTF-8");

        int idPublication =
            Integer.parseInt("" + request.getSession().getAttribute("idPublication"));
        String title = request.getParameter("title");
        String publicationIssue = request.getParameter("publicationIsse");
        String year = request.getParameter("year");
        String numberPage = request.getParameter("numberPage");
        String link = request.getParameter("link");
        String type = request.getParameter("type");
        String authors = request.getParameter("otherAuthors");
        String pAbstract = request.getParameter("abstract");

        HttpSession session = request.getSession();
        PhdStudent loggedPerson = (PhdStudent) session.getAttribute("phdStudent"); // da verificare

        Publication publication = new Publication();

        publication.setTitle(title);
        publication.setPublicationIssue(publicationIssue);
        publication.setYear(year);
        publication.setNumberPages(Integer.parseInt(numberPage));
        publication.setLink(link);
        publication.setType(type);
        publication.setAuthors(authors);
        publication.setAbstract(pAbstract);
        publication.setFkPhdstudent(loggedPerson.getfkAccount()); // da modificare ancora

        PublicationManager.getInstance().update(idPublication, publication);
        result.put("result", true);

        out.println("<script type=\"text/javascript\">");
        out.println("alert('La pubblicazione è stata modificata.');");
        out.println("location='publicationActivity.jsp';");
        out.println("</script>");
      } catch (SQLException ex) {
        Logger.getLogger(UpdatePublicationServlet.class.getName()).log(Level.SEVERE, null, ex);
        result.put("result", false);
      } catch (ClassNotFoundException ex) {
        Logger.getLogger(UpdatePublicationServlet.class.getName()).log(Level.SEVERE, null, ex);
      }
      out.write(result.toString());

    } catch (JSONException ex) {
      Logger.getLogger(UpdatePublicationServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
  }