File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes how to download a zip file from database? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "how to download a zip file from database?" Watch "how to download a zip file from database?" New topic
Author

how to download a zip file from database?

vidhi sanghavi
Greenhorn

Joined: Mar 28, 2009
Posts: 13
Hi

I have a zip file physically stored in database.
I need to read the file from database and download it .
When I tried to get the data from database using getAsciiStream and wrote it using FileWriter zip file got created but unzipping the file gives error..
I also tried unzipping the zip file but that also gave an exception

Please help!!!

Thanks in Advance

Vidhi
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
You should use rs.getBinaryStream for reading BLOB columns.
vidhi sanghavi
Greenhorn

Joined: Mar 28, 2009
Posts: 13
Hi

I forgot to mention the data is stored as CLOB in database.

Thanks
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
Why is it a CLOB and not a BLOB? It's not text, is it?
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

vidhi

Could you provide the full stack trace of the exception you are getting?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

If you attempt to present a ZIP file from a JSF view, JSF will corrupt it. Same for PDF's, Word documents, Excel spreadsheets and any other non-HTML file format. JSF is expecting to output HTML and only HTML.

Use an ordinary servlet to present the ZIP file for download. JSF is not greedy, it won't mind.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to download a zip file from database?