Hi. I am trying to have my
servlet write a file to the client machine and have come across a strange problem. If I enter
on my web browser, the file gets downloaded to the client machine. However, if I call the same code via some JavaScript, the code I call runs without any problems but the file does not get written. This is the relevant portion of the servlet
I have doGet (and doPost) set up to simply call this function with the relevant parameters.
The log file if I call this servlet directly from the browser is:
The log output is
exactly the same if I call the doGet (or doPost) from Javascript. Just that the file does not get written to disk (I am using linux and issued a find as root across the entire file system in case the file was downloaded but written somewhere else).
Here is the code I am using to make the call
Can anyone shed some light on this? I get the same result on Windows and Linux using Firefox and Chrome. As an aside - maybe related - I thought that setting the response header to have a Content-Disposition of attachment would prompt the browser to ask the user where to place the file, but it doesn't do that no matter how I invoke doDownload.