1

I have a download servlet which generates a ZIP with some files, one of them pretty big, and then sends the generated file in the response for download.

The problem is that the generating process is pretty big, and between the step of the generation of de ZIP and the download step (when the user see the download dialog) many seconds or even a minute could pass. So I would like to inform the user by anyway that the file is being generated.

The solution I'm thinking about is doing several requests, one for open a modal window which informs the user and inside this, then do another request automatically to an action which generates the file in a temp location and then, when the request ends, another one which closes the window (the window must be closed automatically) and then request to the download servlet the generated file in the last step.

If somebody understands what I'm trying to do, I would like if exists a better and cleaner solution.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38

1 Answers1

1

You can fire an ajax request which will start the generation process, and then other ajax requests to poll the server if the file is ready. If yes - change the location of the browser to the file. Otherwise, show a "loading" message/image/..

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • I was thinking about using Ajax before, but this is an old project and for several reasons that are difficult to explain, I should better not install and use Ajax. – Alejandro García Seco Jan 27 '11 at 09:19