jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes Struts-JASPER integration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts-JASPER integration" Watch "Struts-JASPER integration" New topic
Author

Struts-JASPER integration

Sandeep K Shah
Greenhorn

Joined: Jan 31, 2008
Posts: 1
Hi All,

We are using Struts based framework. We want to configure struts with JasperReport to fulfill some printing requirements.

In order to print the report we need to provide Response Outputstream to JasperReport.

We have written following lines of code in Action class for this purpose.
e.g.
JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, this.response.getOutputStream());
exporter.exportReport();

Jasper report is supposed to write onto this OutputStream, but it throws following runtime error.

java.lang.IllegalStateException: getOutputStream() has already been called for this response
org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:619)
org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:181)
org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:143)
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:136)
org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:345)
org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:356)
org.apache.jasper.runtime.JspWriterImpl.print(JspWriterImpl.java:481)
com.mastek.jspx.web.ui.taglib.FormTag.doEndTag(Unknown Source)
org.apache.jsp.form.PrintOptionForm_jsp._jspx_meth_jspxt_form_0(PrintOptionForm_jsp.java:199)
org.apache.jsp.form.PrintOptionForm_jsp._jspService(PrintOptionForm_jsp.java:143)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:251)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.GeneratedMethodAccessor666.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
java.security.AccessController.doPrivileged(Native Method)
java.security.AccessController.doPrivileged(Native Method)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.GeneratedMethodAccessor666.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
java.security.AccessController.doPrivileged(Native Method)
com.bt.nhs.spine.dsa.servlet.DSAFilter.doFilter(DSAFilter.java:181)

Can anybody tell me when this error occurs and is it something to do with JASPER?
 
jQuery in Action, 2nd edition
 
subject: Struts-JASPER integration