wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes Error: getOutputStream() has already been called for this reponse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Error: getOutputStream() has already been called for this reponse" Watch "Error: getOutputStream() has already been called for this reponse" New topic
Author

Error: getOutputStream() has already been called for this reponse

nguyen cuong
Greenhorn

Joined: Oct 29, 2010
Posts: 3
hi all, I'm a newbie, so I lack experience on solving some errors, I really appreciate if you help me to solve this.
I got a error

I tried to implement iReport into my web project. I used Netbean to create the project.
I have 2 classes: ConnectionManager.java and JaperReportWrapper.java
The first one is used to connect with the database, I can handle it.
The second one is used to connect the database with iReport and some method to compile a JRXML file and export into a PDF file.
I also created a jsp file: CustomerInvoicesReports.jsp
Here is this:

Maybe the errors occurred at this line

Because when I deleted it, the error disappeared.
Any body help me, please. I really appreciate this.
PS: The JasperReportWrapper.java is following:
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

You are trying to mix text (the automatic variable "out", which is used for the HTML start, and even the line breaks after your JSP directives) with binary (response.getOutputStream()). That's not going to work. Instead try JRExporterParameter.OUTPUT_WRITER combined with that automatic variable "out":


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
nguyen cuong
Greenhorn

Joined: Oct 29, 2010
Posts: 3
It really works. The error has disappeared. But my purpose is to export a PDF file from a iReport file(*.RXML), instead the screen would show a PDF file, it's appeared a prompt

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

So you want to create a PDF file? Then drop most of that page. That is generating HTML; check the content type.

What you would need to do to generate PDF from a JSP is this:
1) set the proper content type
2) do not use any text, including text between JSP directives and/or other JSP tags
3) use response.getOutputStream() again

Step 2 is very important, as without it the JSP file will use the default JspWriter instead of OutputStream, and you will get your error again.


Or, the simpler approach, use a servlet instead of JSP.
nguyen cuong
Greenhorn

Joined: Oct 29, 2010
Posts: 3
Can you be more specific? A sample will be better for me, I even don't know how to do what you told I'm so poor
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error: getOutputStream() has already been called for this reponse
 
Similar Threads
file .jasper and jsp
jasperreports does not work in executable jar file
Same Jasper Report keeps opening
Jasper Reports Exception
Jasper subreport not getting displayed when Jasper print is called twice