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

how to download a file.......

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
From the remote location, i want to download a file using JSP.
how to do it ???
Thanks,
Yegappan
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest method is to read the file using FileInputStream from the server, change its content type to 'application/octet-stream' and append it to the ServeltResponse. The browser will pop up the download window and the user can save the file to his harddisk.

------------------
--:Biju:--
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Biju Nair:
The easiest method is to read the file using FileInputStream from the server, change its content type to 'application/octet-stream' and append it to the ServeltResponse. The browser will pop up the download window and the user can save the file to his harddisk.


I wouldn't say that's the EASIEST way but it is probably the best way.
Depending on the type of file, you can use http headers and the mime type to download the file. For instance, if you are downloading a comma separated value (csv) file, you set the mime type to text/csv and then just redirect the browser to the file. Depending on how the browser's mime types are set up, you might get a download dialog box or it might just load the file in the browser. The point is, doing it this way is browser (client) specific and that may not be what you want. However, there is a lot of flexibility in using mime types and you may be able to achieve the effect you are looking for very easily.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a package specifically done for uploading a file and downloading in oreilly's site
Use Multipart request classes for doing your stuff
Download the package from www.oreilly.com
[ January 04, 2002: Message edited by: hkg ]
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Find For in google JSP SMARD loader download it this u can implement for uploading files from a remote PC
sandeep balyan
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by sandeep balyan:
JSP SMARD


"jspSmartUpload", which you could find on
www.jspsmart.com
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
I wanted a help in downloading files. I am actually using Jspsmartupload for downloading.
It is working fine. However the probelem is that everytime I click for the file to be downloaded ,rather than showing a pop up window it straight away shows the content in the browser. This is true for the generally understood files like .jpeg, .doc,.txt.
Only when I give a not so common file extension will then the pop up window come and ask if I want to save the file ...

Hence how do I ensure that irrespective of the type of file , a window always pops up asking if I want to save the file ....
I guess it might be something to do with the mime type , so please remember that I am using Jspsmartupload.
Thanks in advance,
Regards,
Milan Doshi
 
What's wrong? Where are you going? Stop! Read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic