Forum Stats

  • 3,854,257 Users
  • 2,264,344 Discussions
  • 7,905,623 Comments

Discussions

download file from server in jsp

844047
844047 Member Posts: 12
hi i have uploaded a file to my server,,

now i have to create a link for that file and download it to the client machine again.... how to perform this task..??

Answers

  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy
    841044 wrote:
    hi i have uploaded a file to my server,,

    now i have to create a link for that file and download it to the client machine again.... how to perform this task..??
    The downloading part the browser does for you, so no worries there. If you want a user to be able to download a file, the browser has to be able to reach it through a HTTP call. So either put files in your application's webroot folder (terrible idea) or create a Servlet that can load the data from disc and output it as an octet-stream to the HTTP response object. You don't have to write this yourself, I suggest you apply an existing file servlet like BalusC's one.

    http://balusc.blogspot.com/2007/07/fileservlet.html
    gimbal2
This discussion has been closed.