Hi Reuben,
there is no way to tell the browser where to download a file to.
Regarding your second question: I think
you should not download the whole PDF first but only the PDF the client is interested in. Here is what I (the
servlet I wrote) would do:
I assume you can only access the full report, and the client can let the server know in which pages the client is interested in:
- get the full PDF
- extract the pages the client is interested in (there are PDF libraries out there, that can help, e.g. iText, see
http://www.rgagnon.com/javadetails/java-0647.html)
- stream this PDF
If the client is not able to let the server know in which pages the client is interested in, the PDF must be split on the client side. I have never done this, so I cannot even tell if it is possible.
BTW, I am not sure what your samle code is supposed to do. Where does the "file" attribute come from? Could you post the entire servlet code?
Moreover, you cannot stream multiple files like you are doing in your code; the only way to achieve this (theoretically), is to use multipart content-type. But as far as I know, the current browsers do not support this. When I needed to stream / download multiple files, I created a zip with the files.
Best regards
Christian