By: Lin Yang - linyang
getOutputStream() has already been called for
2002-11-30 22:54
I can generate pdf from xml successfully, however, it always gives me this error java.lang.IllegalStateException: getOutputStream() has already been called for this response
when I generate pdf from browser.
Here is my sample code in jsp:
bytes =
JasperRunManager.runReportToPdf(
reportPath + "/" + reportFileName + ".jasper",
parameters,
getConnection()
);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
response.getOutputStream().write(bytes);
response.getOutputStream().flush();
response.getOutputStream().close();
I copied the code from sample code compile.jsp.
Anyone knows what causes the error ?
thanks
Lin
By: Teodor Danciu - teodord
RE: getOutputStream() has already been called for
2002-12-01 23:16
Hi,
This is a JSP problem that depends on the way
the Web server deals with the response.
I would try to use servlets instead of JSP when
sending binary content to the browser, because
with servlets you have better control over what
and when you send.
For example, your problem might come from
some blank spaces in your JSP.
I hope this helps.
Teodor
By: Steven Blough - stevenblough
RE: getOutputStream() has already been called for
2002-12-02 05:42
Also check the page you are submitting the report request from. One of our developers had this problem when he had a submit button invoking javascript that also submitted the page. This was causing 2 threads to be spawned for the same request. His problem was fixed by changing the submit button to a normal button.
Good luck
Steven Blough
getOutputStream() has already been called for
2002-11-30 22:54
I can generate pdf from xml successfully, however, it always gives me this error java.lang.IllegalStateException: getOutputStream() has already been called for this response
when I generate pdf from browser.
Here is my sample code in jsp:
bytes =
JasperRunManager.runReportToPdf(
reportPath + "/" + reportFileName + ".jasper",
parameters,
getConnection()
);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
response.getOutputStream().write(bytes);
response.getOutputStream().flush();
response.getOutputStream().close();
I copied the code from sample code compile.jsp.
Anyone knows what causes the error ?
thanks
Lin
By: Teodor Danciu - teodord
RE: getOutputStream() has already been called for
2002-12-01 23:16
Hi,
This is a JSP problem that depends on the way
the Web server deals with the response.
I would try to use servlets instead of JSP when
sending binary content to the browser, because
with servlets you have better control over what
and when you send.
For example, your problem might come from
some blank spaces in your JSP.
I hope this helps.
Teodor
By: Steven Blough - stevenblough
RE: getOutputStream() has already been called for
2002-12-02 05:42
Also check the page you are submitting the report request from. One of our developers had this problem when he had a submit button invoking javascript that also submitted the page. This was causing 2 threads to be spawned for the same request. His problem was fixed by changing the submit button to a normal button.
Good luck
Steven Blough
0 Answers:
No answers yet