Este es el problema:
No se visualiza el reporte pdf en el navegador, lo que sale es el siguiente texto:
Cita:
En otros casos sale la ventana para guardar el pdf, y lo peor es que no tiene nada de nada. Luego de hacer unos actos de magia accidentales (logj4...), este fue la excepción que se apreciaba en la consola de Apache tomcat 5.5.9 -para cualquiera de los casos anteriores da la misma excepción-%PDF-1.4 %���� 1 0 obj <>stream x�� endstream endobj 3 0
obj<>/MediaBox[0 0 612 792]>> endobj 2 0 obj<> endobj 4 0 obj<> endobj 5 0
obj<> endobj xref 0 6 0000000000 65535 f 0000000015 00000 n 0000000227 0000 n 0000000089 00000 n 0000000277 00000 n 0000000321 00000 n
trailer <<9601e5a0666525a00a7d558476c78d7e>]/Info 5 0 R/Size 6>> startxref 506 %%EOF
obj<>/MediaBox[0 0 612 792]>> endobj 2 0 obj<> endobj 4 0 obj<> endobj 5 0
obj<> endobj xref 0 6 0000000000 65535 f 0000000015 00000 n 0000000227 0000 n 0000000089 00000 n 0000000277 00000 n 0000000321 00000 n
trailer <<9601e5a0666525a00a7d558476c78d7e>]/Info 5 0 R/Size 6>> startxref 506 %%EOF
Cita:
este es el jsp:Comienza el Reporte
Compilamos as.jrxml OK
Cargamos el jasperreports-3.0.0.jar OK*********
Fin de compilado
---F:\jakarta\webapps\aguas\reportes\as.jasper---
jasperPDF OK..............
Fin del reporte ...F:\jakarta\webapps\aguas\reportes\as.jasper
Servlet.service() para servlet jsp lanz¾ excepci¾n java.lang.IllegalStateException: getOutputStream() ya ha sido llamado para esta
respuesta at org.apache.catalina.connector.Response.getWriter(R esponse.java:596) at org.apache.catalina.connector.ResponseFacade.getWr iter(ResponseFacade
.java:186) at org.apache.jasper.runtime.JspWriterImpl.initOut(Js pWriterImpl.java:124) at org.apache.jasper.runtime.JspWriterImpl.flushBuffe r(JspWriterImpl.java:117)at org.apache.jasper.runtime.PageContextImpl.release( PageContextImpl.java:191)
at org.apache.jasper.runtime.JspFactoryImpl.internalR eleasePageContext(J
spFactoryImpl.java:115) at org.apache.jasper.runtime.JspFactoryImpl.releasePa geContext(JspFactoryImpl.java:75)
at org.apache.jsp.admin.reportes_jsp._jspService(org. apache.jsp.admin.reportes_jsp:215)
at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet .java:802) at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper
.java:322) at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:2
91) at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet .java:802) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextV
alve.java:178) at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.j
ava:105) at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java
:856) at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpo
int.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFol
lowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadP
ool.java:684) at java.lang.Thread.run(Thread.java:619)
Compilamos as.jrxml OK
Cargamos el jasperreports-3.0.0.jar OK*********
Fin de compilado
---F:\jakarta\webapps\aguas\reportes\as.jasper---
jasperPDF OK..............
Fin del reporte ...F:\jakarta\webapps\aguas\reportes\as.jasper
Servlet.service() para servlet jsp lanz¾ excepci¾n java.lang.IllegalStateException: getOutputStream() ya ha sido llamado para esta
respuesta at org.apache.catalina.connector.Response.getWriter(R esponse.java:596) at org.apache.catalina.connector.ResponseFacade.getWr iter(ResponseFacade
.java:186) at org.apache.jasper.runtime.JspWriterImpl.initOut(Js pWriterImpl.java:124) at org.apache.jasper.runtime.JspWriterImpl.flushBuffe r(JspWriterImpl.java:117)at org.apache.jasper.runtime.PageContextImpl.release( PageContextImpl.java:191)
at org.apache.jasper.runtime.JspFactoryImpl.internalR eleasePageContext(J
spFactoryImpl.java:115) at org.apache.jasper.runtime.JspFactoryImpl.releasePa geContext(JspFactoryImpl.java:75)
at org.apache.jsp.admin.reportes_jsp._jspService(org. apache.jsp.admin.reportes_jsp:215)
at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet .java:802) at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper
.java:322) at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:2
91) at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet .java:802) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextV
alve.java:178) at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.j
ava:105) at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java
:856) at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpo
int.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFol
lowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadP
ool.java:684) at java.lang.Thread.run(Thread.java:619)
Cita:
En fin, es la primera ves que trabajo con iReport, el 3.0.0, he seguido las instrucciones que todos señalan, eso al menos espero. Porfavor guienme a la solucion, gracias<%@ page import="net.sf.jasperreports.engine.*" %>
<%@ page import="net.sf.jasperreports.engine.design.*" %>
<%@ page import="net.sf.jasperreports.engine.data.*"%>
<%@ page import="net.sf.jasperreports.engine.export.*"%>
<%@ page import="net.sf.jasperreports.engine.util.*"%>
<%@ page import="net.sf.jasperreports.view.*"%>
<%@ page import="net.sf.jasperreports.view.save.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<% try{ ResultSet rs = null; Statement st = null; String sql = null; String driver = "org.postgresql.Driver"; String connectString = "prueba"; String user ="postgres"; String password = ".postgres"; Class.forName(driver); Connection conn = DriverManager.getConnection(connectString, user, password);
////////////Compilamos as.jrxml
System.setProperty( "jasper.reports.compile.class.path", application.getRealPath("/WEB-INF/lib/jasperreports-3.0.0.jar") + System.getProperty("path.separator") + application.getRealPath("/WEB-INF/classes/") );
////////////Cargamos el jasperreports-3.0.0.jar
System.setProperty("jasper.reports.compile.temp",a pplication.getRealPath("/reportes/"));
JasperCompileManager.compileReportToFile(applicati on.getRealPath("/reportes/as.jrxml"));
///////////Fin de compilado
File reportFile = new File(application.getRealPath("/reportes/as.jasper"));
Map parameters = new HashMap();
byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath (),parameters,conn);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
///////////////////////////////////////////////////////////////
}
catch (JRException e)
{System.out.println("Errores:" +e.getMessage());}
catch (Exception e)
{e.printStackTrace(); System.out.println("Error2:"+e.getMessage());
} %>
<%@ page import="net.sf.jasperreports.engine.design.*" %>
<%@ page import="net.sf.jasperreports.engine.data.*"%>
<%@ page import="net.sf.jasperreports.engine.export.*"%>
<%@ page import="net.sf.jasperreports.engine.util.*"%>
<%@ page import="net.sf.jasperreports.view.*"%>
<%@ page import="net.sf.jasperreports.view.save.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<% try{ ResultSet rs = null; Statement st = null; String sql = null; String driver = "org.postgresql.Driver"; String connectString = "prueba"; String user ="postgres"; String password = ".postgres"; Class.forName(driver); Connection conn = DriverManager.getConnection(connectString, user, password);
////////////Compilamos as.jrxml
System.setProperty( "jasper.reports.compile.class.path", application.getRealPath("/WEB-INF/lib/jasperreports-3.0.0.jar") + System.getProperty("path.separator") + application.getRealPath("/WEB-INF/classes/") );
////////////Cargamos el jasperreports-3.0.0.jar
System.setProperty("jasper.reports.compile.temp",a pplication.getRealPath("/reportes/"));
JasperCompileManager.compileReportToFile(applicati on.getRealPath("/reportes/as.jrxml"));
///////////Fin de compilado
File reportFile = new File(application.getRealPath("/reportes/as.jasper"));
Map parameters = new HashMap();
byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath (),parameters,conn);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
///////////////////////////////////////////////////////////////
}
catch (JRException e)
{System.out.println("Errores:" +e.getMessage());}
catch (Exception e)
{e.printStackTrace(); System.out.println("Error2:"+e.getMessage());
} %>
Para mayor informacion estos son los jar y aplicaciones que uso:
Cita:
estos jar tambien estan copiados en el proyecto "/web-inf/lib"iReport
commons-logging-api-1.0.2
commons-vfs-1.0
commons-digester-1.7
log4j-1.2.9
commons-collections-2.1
jasperreports-3.0.0
commons-dbcp-1.2.1
commons-pool-1.3
itext-1.3.1
poi-3.0.1-FINAL-20070705
commons-httpclient-3.1
commons-beanutils-1.7
commons-logging-1.0.2
commons-javaflow-20060411
commons-codec-1.3
commons-math-1.0
commons-logging-api-1.0.2
commons-vfs-1.0
commons-digester-1.7
log4j-1.2.9
commons-collections-2.1
jasperreports-3.0.0
commons-dbcp-1.2.1
commons-pool-1.3
itext-1.3.1
poi-3.0.1-FINAL-20070705
commons-httpclient-3.1
commons-beanutils-1.7
commons-logging-1.0.2
commons-javaflow-20060411
commons-codec-1.3
commons-math-1.0
Cita:
apache Tomcat 5.5.9
jdk 1.6.0_01
ireport 3.0.0
adobe acrobat 5 and 7
jdk 1.6.0_01
ireport 3.0.0
adobe acrobat 5 and 7