wood burning stoves 2.0*
The moose likes Struts and the fly likes File download from Blob column does not work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "File download from Blob column does not work" Watch "File download from Blob column does not work" New topic
Author

File download from Blob column does not work

hasina kumar
Greenhorn

Joined: Jan 06, 2006
Posts: 9
I am trying to download a file from a blob column in the database in my action class. I know that blob object was correclty populated in the first place by uploading a file. I can verify that by clicking the blob field in TOAD.
No matter what the size of the file is, it always downloads only 3k, and when i try to open the file, it says it cannot determine the type of the file. I am using Oc4j Application server with oracle database(9.2.0.5). I got the latest jdbc driver for this database version and put in my oc4j lib folder. My action class looks like:
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you're downloading the file you need to be writing to the HttpServletResponse's OutputStream, not to a FileOutputStream.

try this code:



Merrill
Consultant, Sima Solutions
hasina kumar
Greenhorn

Joined: Jan 06, 2006
Posts: 9
Initially that was what i was doing trying to do, to write to ServletOutputStream from the response object. But i kept on getting "Writer already retrieved error", so i used FileOutputStream instead. But finally i figured out why i was getting the error while using response.getOutputStream(). So myster solved . Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File download from Blob column does not work