no iReport mostra normal, no borwse nao o que pode esta errado no codigo:
ServletOutputStream servletOutputStream = response.getOutputStream();
String caminho = "/report/";
String relatorio = caminho+"report2.jasper";
InputStream reportStream =
getServletConfig().getServletContext().getResourceAsStream(relatorio);
Connection connection = null;
try {
//cria a conexão com o banco de dados
Class.forName(“com.mysql.jdbc.Driver”);
String db = “jdbc:mysql://localhost:3306/lvisitas”;
connection = (Connection) DriverManager.getConnection(db,“root”,“root”);
// envia o relatório em formato PDF para o browser
response.setContentType(“application/pdf”);
//para gerar o relatório no formato PDF
// o método runReportToPdfStream foi usado
JasperRunManager.runReportToPdfStream(reportStream,
servletOutputStream, new HashMap(),connection);
} catch (ClassNotFoundException ex) {
Logger.getLogger(Relatorio.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(Relatorio.class.getName()).log(Level.SEVERE, null, ex);
}
catch (JRException e) {
Logger.getLogger(Relatorio.class.getName()).log(Level.SEVERE, null, e);
}
finally{
servletOutputStream.flush();
servletOutputStream.close();
try {
if (connection != null) {
connection.close();
}
} catch (SQLException ex) {
Logger.getLogger(Relatorio.class.getName()).log(Level.SEVERE, null, ex);
}
}