Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » setOutputStream closes the stream after processing.
setOutputStream closes the stream after processing. [message #362712] Wed, 21 May 2008 22: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 13: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 14:23 Go to previous messageGo to next message
Ibo 2050 is currently offline Ibo 2050Friend
Messages: 1
Registered: December 2013
Junior Member
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 179 times)
Re: setOutputStream closes the stream after processing. [message #1220828 is a reply to message #1220553] Fri, 13 December 2013 22:10 Go to previous message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

What is your BIRT version?

Michael

Developer Evangelist, Silanis
Previous Topic:Relative time period & crostab filters
Next Topic:MSung-Light Font in PDF with Russian characters
Goto Forum:
  


Current Time: Fri Apr 19 12:38:29 GMT 2024

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

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

Back to the top