Reputation: 1673
How do you force a download prompt to popup before you send any data to browser? I know about content disposition attachment, but this is different. Basically, the servlet starts sending data to the client, and then the client open a dialog, open, save, cancel.
The probably is my servlet is slow getting the data, and it gets all the data in memoery before it sends any thing to the client. I would like to do something to trigger the dialog, before I am ready to send the data. Otherwise, the browser just waits there, like you did nothing.
I want to trigger that save dialog sooner. I can't send data, because the data is not ready.
Any ideas?
Grae
Upvotes: 1
Views: 1180
Reputation: 1005
If you want your app to appear more responsive to the user (and prevent multiple clicks on the download link) consider to make the link point to a location (servlet or JSP) which does nothing but issue a 301/302 redirect with a reponse body, i.e. an HTML page displaying a message asking the user to be patient while the data is collected. The redirect's location should then point to your servlet which delivers the download.
Upvotes: 1
Reputation: 93177
You can simply use the OutputStream
and send data over it. This way you don't have to get the whole data in memory.
On the same topic :
Upvotes: 0