This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 31st, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,380 Users
  • 2,269,776 Discussions
  • 7,916,824 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 Senior software engineer NetherlandsMember 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.