Skip to main content



      Home
Home » Archived » BIRT » setOutputStream closes the stream after processing.
setOutputStream closes the stream after processing. [message #362712] Wed, 21 May 2008 18:54 Go to next message
Eclipse UserFriend
Originally posted by: user.example.net

Greetings
I'm using the Birt engine to embed the contents of a report in a
servlet. I pass the response outputstream directly to the engine, but I
find that the stream has been closed when the report is complete.
Is there a way to disable this? As a workaround I could create a stream
and convert it to a string, but I'm not sure if this sound.
Thank you, Achile B.

shortened code:

doGet(request, response)
ServletOutputStream stream = response.getOutputStream();
stream.write("Text before..".getBytes()); //Does display

//start engine, set params, settings,init task & renderoptions
htmlOptions.setHtmlRtLFlag(false);
htmlOptions.setEmbeddable(true);
htmlOptions.setOutputStream(stream );
htmlOptions.setOutputFormat("html");
task.setRenderOption(htmlOptions);
task.run();

stream.write("Text after..".getBytes()); //Does not print (!)
//stream is closed.


Workaround:
ByteArrayOutputStream foo = new ByteArrayOutputStream();
htmlOptions.setOutputStream(foo);
out.write(new String(foo.toByteArray()));
Re: setOutputStream closes the stream after processing. [message #363267 is a reply to message #362712] Tue, 17 June 2008 09:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mil.methodpark.de

Hello Achile,

I have had the same problem like you and used exactly the same workaround.
Did you perhaps find another solution meanwhile?

Regards,
Matthias

"Achille" <user@example.net> schrieb im Newsbeitrag
news:g1295e$kmm$1@build.eclipse.org...
> Greetings
> I'm using the Birt engine to embed the contents of a report in a servlet.
> I pass the response outputstream directly to the engine, but I find that
> the stream has been closed when the report is complete.
> Is there a way to disable this? As a workaround I could create a stream
> and convert it to a string, but I'm not sure if this sound.
> Thank you, Achile B.
>
> shortened code:
>
> doGet(request, response)
> ServletOutputStream stream = response.getOutputStream();
> stream.write("Text before..".getBytes()); //Does display
>
> //start engine, set params, settings,init task & renderoptions
> htmlOptions.setHtmlRtLFlag(false);
> htmlOptions.setEmbeddable(true);
> htmlOptions.setOutputStream(stream );
> htmlOptions.setOutputFormat("html");
> task.setRenderOption(htmlOptions);
> task.run();
>
> stream.write("Text after..".getBytes()); //Does not print (!)
> //stream is closed.
>
>
> Workaround:
> ByteArrayOutputStream foo = new ByteArrayOutputStream();
> htmlOptions.setOutputStream(foo);
> out.write(new String(foo.toByteArray()));
Re: setOutputStream closes the stream after processing. [message #1220553 is a reply to message #362712] Thu, 12 December 2013 09:23 Go to previous messageGo to next message
Eclipse UserFriend
Hallo everybody,
I have the same problem, anyone has idee,
please help us

IRenderOption renderOption = this.getRenderOption(format);

reportingTask.setRenderOption(renderOption);

ByteArrayOutputStream reportOutput= (ByteArrayOutputStream)renderOption.getOutputStream();

when I send 2 Requestt (Parallel) I get only one Response, the other reponse can not process it, because the outputstream is already in use....... Crying or Very Sad Crying or Very Sad



private static final Logger LOGGER = Logger.getLogger(DefaultReportService.class.getName());
IRunAndRenderTask reportingTask = null;

public byte[] report(Format format, InputStream design, List<String> dataSourceNames, Map<String, String>dataSourcePropeties) {
this.init(design, dataSourceNames, dataSourcePropeties);
IRenderOption renderOption = this.getRenderOption(format);
reportingTask.setRenderOption(renderOption);
try {
reportingTask.run();
} catch (EngineException e) {
LOGGER.error("EngineException exception while creating report.", e);
e.printStackTrace();
} catch (Exception e){
LOGGER.error("Unexpecte exception while creating report." + e.getClass()+ " " + e.getMessage(), e);
e.printStackTrace();
} finally{
reportingTask.close();
}

ByteArrayOutputStream reportOutput = (ByteArrayOutputStream)renderOption.getOutputStream();

return reportOutput.toByteArray();
}
  • Attachment: delete.JPG
    (Size: 55.08KB, Downloaded 203 times)
Re: setOutputStream closes the stream after processing. [message #1220828 is a reply to message #1220553] Fri, 13 December 2013 17:10 Go to previous message
Eclipse UserFriend
What is your BIRT version?
Previous Topic:Relative time period & crostab filters
Next Topic:MSung-Light Font in PDF with Russian characters
Goto Forum:
  


Current Time: Wed Jun 25 05:00:56 EDT 2025

Powered by FUDForum. Page generated in 0.29309 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top