[RESOLVIDO]Relatorio jasper vem corrompido

Galera estou tentando chamar um relatorio a partir de um servlet. Eu baixo o relatorio e tudo, mas ele vem corrompido, com zero bytes. Segue o codigo do servlet:

public class relatorio extends HttpServlet {
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            
            JasperPrint jasperPrint = JasperFillManager.fillReport("C:\\relatorio.jasper", new HashMap(), Conexao.conectar());
            byte bytes[] = JasperExportManager.exportReportToPdf(jasperPrint);
            response.setContentType("application/pdf");
            response.setHeader("Content-disposition", "inline;filename=arquivo.pdf");
            response.setHeader("Content-disposition", "attachment;filename=arquivo.pdf");
            response.getOutputStream().write(bytes);
            response.getCharacterEncoding();
            FacesContext.getCurrentInstance().responseComplete();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            out.close();
        }
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }
    public String getServletInfo() {
        return "Short description";
    }
}

Alguem pode me ajudar?

Alguem?

Vc nao ta mandando nada para o relatório…

como quer q ele te traga algo?

[quote=TheKill]Vc nao ta mandando nada para o relatório…

como quer q ele te traga algo?[/quote]

O q esta faltando? Achei q o response.getOutputStream().write(bytes) escreveria na saida o arquivo gerado pelo JasperExportManager.exportReportToPdf(jasperPrint), pelo menos era assim q estavam os exemplos q eu vi.

web eu nao manjo, mas tem algo errado ai…

desculpe não poder ajudar

[quote=Basilio]Galera estou tentando chamar um relatorio a partir de um servlet. Eu baixo o relatorio e tudo, mas ele vem corrompido, com zero bytes. Segue o codigo do servlet:

[code]
public class relatorio extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(“text/html;charset=UTF-8”);
PrintWriter out = response.getWriter();
try {

        JasperPrint jasperPrint = JasperFillManager.fillReport("C:\\relatorio.jasper", new HashMap(), Conexao.conectar());
        byte bytes[] = JasperExportManager.exportReportToPdf(jasperPrint);
        response.setContentType("application/pdf");
        response.setHeader("Content-disposition", "inline;filename=arquivo.pdf");
        response.setHeader("Content-disposition", "attachment;filename=arquivo.pdf");
        response.getOutputStream().write(bytes);
        response.getCharacterEncoding();
        FacesContext.getCurrentInstance().responseComplete();

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        out.close();
    }
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);
}
public String getServletInfo() {
    return "Short description";
}

}

[/code][/quote]

o erro esta na linha 5, é so comentar essa linha q da certo. Se alguem precisar…

public class relatorio extends HttpServlet {
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try {
            
            JasperPrint jasperPrint = JasperFillManager.fillReport("C:\\relatorio.jasper", new HashMap(), Conexao.conectar());
            byte bytes[] = JasperExportManager.exportReportToPdf(jasperPrint);
            response.setContentType("application/pdf");
            response.setHeader("Content-disposition", "inline;filename=arquivo.pdf");
            response.setHeader("Content-disposition", "attachment;filename=arquivo.pdf");
            response.getOutputStream().write(bytes);
            response.getCharacterEncoding();
            FacesContext.getCurrentInstance().responseComplete();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            out.close();
        }
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }
    public String getServletInfo() {
        return "Short description";
    }
}