• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

file download using servlet and showing progress

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

In my web application, I need to provide functionality to enable downloading of a file from the server using a servlet. After having provided that functionality by means of the following code,


I now need to display progress/status as to whats happening on the server side. The file being downloaded is a result of a few operations like generating pdfs and merging them. This takes quite some time and until then the client is left in the dark and all he can does is stare at a blank browser window. So as to enrich user experience I wanted to show progress of the files being merged and also the size of the end file that has been downloaded before it finally opens on the browser window, Is this possible and is there any particular pattern to follow.

Thanks

Vijai
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do this by kicking off the long running process in a new thread and then immediately returning the user to a status page.
The status page refreshes itself (using a META tag) every n seconds to check with server. If the job is not done, I return the status page. Once it's finished, I stream the file or forward to a page with a link to the file.

If you're interested, I have a small demo app that does this.
http://simple.souther.us/not-so-simple.html
Look for LongRunningProcess.
 
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To reduce page flickering you can use JavaScript with a timer for updating only status bar.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vijjai,

Can you please post your solution to your problem in case you have!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic