protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        session.removeAttribute("error");
        session.removeAttribute("sucesso");

        Usuario user = (Usuario) session.getAttribute("user");
        String idNoticiaS = request.getParameter("idNoticia");
        
        try {
            int id = Integer.parseInt(idNoticiaS);
            if(user != null && user instanceof Editor){
                //Editor editor = (Editor) user;

                NoticiaDAO dao = new NoticiaDAO();
                dao.excluir(id);

                ArrayList<Noticia> noticias = (ArrayList<Noticia>) session.getAttribute("noticias");
                if(noticias != null){
                    for (int i = 0; i < noticias.size(); i++) {
                        if (noticias.get(i).getId() == id) {
                            noticias.remove(i);
                        }
                    }
                }
                
                //editor.removerNoticia(id);
                session.setAttribute("sucesso", "Notícia removida com sucesso.");
                response.sendRedirect(request.getContextPath() + "/index.jsp");

            }else{
                session.setAttribute("error", "Voce nao tem permissao para acessar essa area.");
                response.sendRedirect(request.getContextPath() + "/index.jsp");
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
            session.invalidate();
            response.sendRedirect(request.getContextPath() + "/index.jsp");
        } catch (Exception ex){
            ex.printStackTrace();
            session.invalidate();
            response.sendRedirect(request.getContextPath() + "/index.jsp");
        }
    }