1
resposta

HTTP Status 500 – Internal Server Error

Type Exception Report Message: Cannot call sendRedirect() after the response has been committed

Alguém consegue me informar o motivo de cair nessa exception?

/alteraEmpresa:

    System.out.println("Alterando empresa");

    String nomeEmpresa = request.getParameter("nome");
    String paramDataEmpresa = request.getParameter("data");
    String paramId = request.getParameter("id");
    Integer id = Integer.valueOf(paramId);

    Date dataAbertura = null;
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        dataAbertura = sdf.parse(paramDataEmpresa);
    } catch (ParseException e) {
        throw new ServletException(e);
    }

    System.out.println(id);

    Banco banco = new Banco();
    Empresa empresa = banco.buscaEmpresaPelaId(id);
    empresa.setNome(nomeEmpresa);
    empresa.setDataAbertura(dataAbertura);

    response.sendRedirect("listaEmpresas");
}
1 resposta

Seu erro deve estar em outro arquivo aparentemente.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software