Serving binary content along with page refresh

S

sasuke

Hello to all Java programmers out there.

I am currently faced with a weird scenario in which I have to serve
binary content to the client (using content disposition header) and at
the same time refresh the page so that it's contents are reloaded. I
am using JSF as a UI framework with JSP being the display technology.

The problem I am facing is that as soon as the content is generated,
any efforts to redirect the client or reload the page results in a
"Response already committed" exception. i.e. as soon as the client is
presented with the Open/Save dialog, no page refresh /redirection
takes place the way it normally happens. Is there any way using which
we can spit out the binary file to the client and at the same time
continue with the normal request - response cycle so that a page
refresh takes place?

Any suggestions / links would be highly appreciated.

Thanks and regards,
sasuke.
 
C

Chris

sasuke said:
Hello to all Java programmers out there.

I am currently faced with a weird scenario in which I have to serve
binary content to the client (using content disposition header) and at
the same time refresh the page so that it's contents are reloaded. I
am using JSF as a UI framework with JSP being the display technology.

The problem I am facing is that as soon as the content is generated,
any efforts to redirect the client or reload the page results in a
"Response already committed" exception. i.e. as soon as the client is
presented with the Open/Save dialog, no page refresh /redirection
takes place the way it normally happens. Is there any way using which
we can spit out the binary file to the client and at the same time
continue with the normal request - response cycle so that a page
refresh takes place?

Any suggestions / links would be highly appreciated.

Thanks and regards,
sasuke.

This is not the answer you're looking for, but I would put a link to the
binary content on the page itself, and let the user fetch the data on
their own in a separate request.

Another idea, probably won't work: you could increase the size of the
JSP page buffer, so nothing gets sent to client side until the entire
page is created.

Another idea: go to a site that works the way you want (maybe the
sourceforge download page?) and see what they do under the covers.
Examine the headers and the data that come back.
 
S

sasuke

This is not the answer you're looking for, but I would put a link to the
binary content on the page itself, and let the user fetch the data on
their own in a separate request.

Another idea, probably won't work: you could increase the size of the
JSP page buffer, so nothing gets sent to client side until the entire
page is created.

Another idea: go to a site that works the way you want (maybe the
sourceforge download page?) and see what they do under the covers.
Examine the headers and the data that come back.

Thanks a lot for your reply. Yeah you were right, the sourceforge page
does exactly what I need though I am pretty confused of how they do
it. Maybe I am still in haze as to how the HTTP Response works.

Here is what I think of it: The HTTP Request sent by the client can be
treated in two ways: either the client action sends the client to same/
another page in which the HTTP Respose is the page given back to the
user. Or the client is served with some data and the page is never
refreshed. In this case the response is the data served back to the
client.

The confusing part here is that what I need and the way sourceforge
page works goes against my understanding of how HTTP response works.
Can someone please correct my flawed understanding and help me achieve
my purpose? Any links to articles/snippets would be greatly
appreciated.

Thanks and regards,
sasuke.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top