protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    Long id = Long.valueOf(request.getParameter("id"));
    Contact contact = contactService.getById(id);

    HttpSession session = request.getSession();

    if (contact != null) {
      contactService.remove(id);

      try {
        conversationService.removeConversationByUserAndContact(
            new JSONObject()
                .put("userId", ((User) session.getAttribute("user")).getId())
                .put("phoneNumber", contact.getPhone()));
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      response.sendRedirect(request.getContextPath() + "/auth/contact");
    } else {
      session.setAttribute(Alert.PRMTR_ERROR, "The contact doesn't exist !");
      request.setAttribute("pageTitle", "Contacts");
      request.getRequestDispatcher("/auth/contact.jsp").forward(request, response);
    }
  }
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String conversationId = request.getParameter("id");

    try {
      List<SMS> sms =
          smsService.getAllSMSByConversation(
              new JSONObject().put("conversationId", conversationId));
      request.setAttribute("sms", sms);

      Conversation conversation =
          conversationService.getConversationById(
              new JSONObject().put("conversationId", Integer.parseInt(conversationId)));
      request.setAttribute("conversationNumber", conversation.getContactName());

      Contact contact =
          contactService.getContactByPhoneAndUser(
              new JSONObject()
                  .put("phone", conversation.getContactName())
                  .put("userId", ((User) request.getSession().getAttribute("user")).getId()));
      if (contact != null)
        conversation.setContactName(contact.getFirstName() + " " + contact.getLastName());

      request.setAttribute("conversation", conversation);
    } catch (JSONException e) {
      e.printStackTrace();
    }

    request.setAttribute("pageTitle", "Conversation");
    request.getRequestDispatcher("/auth/conversation.jsp").forward(request, response);
  }