Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Downloading file from Oracle DB

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written the code to upload and download a file from an Oracle database. (After trying various 3rd party beans for this, I broke down and wrote the code myself using the MultipartParser in the com.oreilly.servlet package) One problem though, is that my code only seems to work for text files. I've read that you somehow have to use the file content-type to download different types of files correctly, but I'm not quite sure how or where to use that information.
Also, ultimately, I would like to have the filenames available listed as urls that when clicked would download the appropriate file and prompt the user to choose whether they want to open it from the current location or save it to disk (as is usually done with files in browsers). I have no idea how to do this. If anyone has any ideas, I would be very grateful for your help.
My code:

Thanks in advance!
--Nicole
[ July 26, 2002: Message edited by: Nicole Swan ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Nicole Swan:
I have written the code to upload and download a file from an Oracle database. (After trying various 3rd party beans for this, I broke down and wrote the code myself using the MultipartParser in the com.oreilly.servlet package) One problem though, is that my code only seems to work for text files. I've read that you somehow have to use the file content-type to download different types of files correctly, but I'm not quite sure how or where to use that information.
Also, ultimately, I would like to have the filenames available listed as urls that when clicked would download the appropriate file and prompt the user to choose whether they want to open it from the current location or save it to disk (as is usually done with files in browsers). I have no idea how to do this. If anyone has any ideas, I would be very grateful for your help.
My code:

Thanks in advance!
--Nicole
[ July 26, 2002: Message edited by: Nicole Swan ]



Hi Nicole,
This is how you set the content type and filename of the file to download.
In your servlet, or whatever:
[CODE]
response.setContentType( "application/pdf" ); //the content type of your downloaded file.
response.setHeader( "Content-Disposition", "filename=MyFileName.pdf" );//Filename set here.
out.print( yourBlobData );
[\CODE]
I think that some versions of IE try to open whatever it can within the browser, so this might
not always cause a "Open/Save" dialog box to pop up.
If you are having trouble with the actual storage/retrieval of the file from the database then check out this post and see if
it helps.
https://coderanch.com/t/354914/Servlets/java/uploading-image-oracle-database-through
I hope this gets you on your way.
Scott Duclos
 
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic