I've put together a
Servlet called DownloadFile that takes in an id for a database record that contains the location of the file I want to load. It's supposed to grab the file and provide the end-user with the option to open or save the file (whatever behavior their browser decides).
When I go into the directory where the files are held, I can open all of the files with the appropriate programs and there aren't any problems with the files.
When I run my web app and try to open or save-then-open the file using the DownloadFile Servlet, I get an error. For example: I've got a PDF file. Using windows explorer and navigating to the document, I can open and view the document in Adobe Acrobat. When I view the file using the DownloadFile Servlet, I get the following error message in Adobe Acrobat: "There was an error opening this document. The file is damaged and could not be repaired."
I will appreciate any help figuring out what I am doing wrong.
Here is my DownloadFile Servlet code: