• 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

Streaming imediatelly

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a question about streaming binary data to the client.
I have discovered that when I start the action which downloads a file, the data is streaming before I decide what to do with it.

If I choose Open, then it eventually opens. but if I choose cancel, I get IllegalStateException.

Is there a way to let the data stream after one chooses what to do?

Thanks
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On a couple occasions I have written actions that returned binary content (images, pdf files, etc.). I have never seen an IllegalStateException. Is this a message that the user sees? What browser are you using?

- Brent
 
Milan Tomc
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Brent,

I'm using IE (requirement), but the same happens with Opera and FF.

The only difference is that with IE it streams about 40kb of data and then it stops until the choice is made. With Opera it streams all the way, and if I wait long enough (until all the data is streamed) and then cancel I get no exception.

I did this to avoid stackTrace in the log:

try{
ServletOutputStream outStream = response.getOutputStream();
dao.getFileData(dataId, outStream);
outStream.flush();
}catch (Exception ilse){
log.info("download canceled - exception:" + ilse.getClass().getName());
}
On the slient side is everything fine. (user sees nothing)
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic