Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Streaming imediatelly

 
Milan Tomc
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • 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
  • 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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic