File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Help needed in writing zip file into response outputstream. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help needed in writing zip file into response outputstream." Watch "Help needed in writing zip file into response outputstream." New topic

Help needed in writing zip file into response outputstream.

Chetan Ram

Joined: Mar 10, 2011
Posts: 20
Hi All,

In our application, we can download files in 2 formats excel and ods (Open document spreadsheet).

In implementation level:

Excel format uses xml i.e. when a excel download is invoked it gets data from database (executing multiple complex queries). Here, each query result is written directly to response (output stream) i.e in the format which is readable by excel file.

for example:

rs = stmt.executeQuery("select * from ABC");
rs = stmt.executeQuery("select * from DEF");

ODS file is a zip file which contains list of xml files. So when user selects ODS format to download then we need to generate all the xml files based on the data retrieved from database (executing multiple complex queries).

So, during this process i am getting Error 400 which says "proxy did not receive data from origin server. so connection was closed".
i.e. proxy server waits for 2 mins to get response from origin server, if it doesn't get any response then it closes the connection.

The problem is : executing db complex queries (takes 2:50 mins) and based on data received we generate 5 xml file and zipping all the files (takes 10 sec) i.e. totally it takes more than 3 mins. And later we pass the zip file to response outputstream. By the time it execute, we get Error 400.

Can anyone let me know if there is any approach where we can keep our response output stream busy, so that we can avoid Error 400 and download successfully or change the ods file download implementation approach?

I agree. Here's the link:
subject: Help needed in writing zip file into response outputstream.
Similar Threads
Not able to put some files inside Zip file
Getting error 400 - Proxy Error: remote host didn't send any data.
Writing data into *.txt file using java
Create Large XLSX Files Using LightCells APIs & Check Empty Columns
Excel to PDF Conversion, XLS, XLSX & ODS Rendering are Improved