File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Streaming xlsx file in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Streaming xlsx file in a servlet" Watch "Streaming xlsx file in a servlet" New topic

Streaming xlsx file in a servlet

dwarakanathan thiru
Ranch Hand

Joined: Oct 14, 2009
Posts: 49
Hi All,

I have been using a common java file that streams contents in a specific file content type. I have used the code to open / save pdf file contents and small excel file contents.
Now, I am trying to dump a huge xlsx file which takes almost 30 minutes to download on our servers, but in my local server, it takes just half the time.

almost one out of 2 times, it also gets timed out (but no error is thrown on the screen), after 30 minutes or so.
Is the timeout related to session inactivity for 30 minutes because of the download that is happening which avoids the user interaction with the screen?

Which is the better option of the two to solve the timeout issue and to improve the performance?
1) Use a temporary file to store the data and then buffer the contents into the stream (This is the option currently in practice)
2) Write directly into the response output stream

Note: I am using POI to generate the xlsx

I appreciate any timely help in this regard.


Dwarak T
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

I believe, using GZIPOutputStream may resolve to a certain extent your time out issue.

Not many get the right opportunity !
I agree. Here's the link:
subject: Streaming xlsx file in a servlet
It's not a secret anymore!