This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Streaming imediatelly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Streaming imediatelly" Watch "Streaming imediatelly" New topic
Author

Streaming imediatelly

Milan Tomc
Greenhorn

Joined: Mar 06, 2006
Posts: 17
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

Joined: Feb 08, 2006
Posts: 948
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

Joined: Mar 06, 2006
Posts: 17
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)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Streaming imediatelly
 
Similar Threads
DB2 VARCHAR Truncation
proxy servlet for pdf byte serving
downloading a file in parts
iPhone data plan
Streaming