1 Reply Latest reply: Sep 12, 2011 3:44 AM by gimbal2 RSS

    download file from server in jsp

    844047
      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..??
        • 1. Re: download file from server in jsp
          gimbal2
          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