Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data Streaming from Java EE Application Server

I need to retrieve from an Application Server (JBoss) a large file (gigabytes) and to avoid loading it in memory, I want to stream it through EJB.

Is it possible to take data out of an Application Server as a stream?

like image 406
Mr.Eddart Avatar asked Feb 21 '23 09:02

Mr.Eddart


1 Answers

Create a HttpServlet, stream the file.

update Be careful with your header. You cannot set the ContentLength-Header via setContentLength(), because it only accept int.

You wil have to set it with: setHeader("Content-Length", (long)length)

Maybe this will be helpful: Using ServletOutputStream to write very large files in a Java servlet without memory issues

There is a limit, but it depends on the client-side. If the client will hold the file in the memory, it will not work.

like image 80
Christian Kuetbach Avatar answered Feb 22 '23 23:02

Christian Kuetbach