/**
   * 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");
    PrintWriter out = response.getWriter();
    try {
      String pacienteIDReq = (String) request.getSession(false).getAttribute("id");
      int id = Integer.parseInt(pacienteIDReq);
      String mail = request.getParameter("mail");
      String pass = request.getParameter("pass");
      Paciente p = new Paciente();
      p.setId(id);
      p.setEmail(mail);
      p.setSenha(pass);
      PacienteDAO pdao = new PacienteDAO();
      pdao.atualizar(p);
      HttpSession httpSession = request.getSession();
      httpSession.removeAttribute("email");
      httpSession.removeAttribute("senha");
      httpSession.setAttribute("email", mail);
      httpSession.setAttribute("senha", pass);
      Paciente p1 = new Paciente();
      Status s = new Status();
      p1.setId(id);
      s.setPaciente(p1);
      StatusDAO sd = new StatusDAO();
      List top = (List) sd.listar(s);
      request.setAttribute("top", top);
      getServletContext().getRequestDispatcher("/homePaciente.jsp").forward(request, response);

    } catch (Exception e) {
      request.setAttribute("status", "erroatualiza");
      getServletContext().getRequestDispatcher("/homePaciente.jsp").forward(request, response);
    } finally {
      out.close();
    }
  }
예제 #2
0
파일: Status.java 프로젝트: cpylua/crawler
 public static Status fromJson(JSONObject json) {
   try {
     Status s = new Status();
     s.setCommentsCount(json.getInt("comments_count"));
     java.util.Date date = parseDate(json.getString("created_at"), "EEE MMM dd HH:mm:ss z yyyy");
     s.setCreatedAt(new Date(date.getTime()));
     s.setId(json.getString("id"));
     s.setRepostsCount(json.getInt("reposts_count"));
     s.setText(json.getString("text"));
     s.setUid(json.getJSONObject("user").getString("id"));
     return s;
   } catch (Exception ex) {
     ex.printStackTrace();
     return null;
   }
 }