samedi 26 septembre 2015

How to interrupt the loading of a webpage?

I know the title is a bit confusing. I will describe my task:

Now I'm writing a webpage, which allow me to download some data or do some other stuff. The front end is jsp and the back end is java. So every time when I do something on this page(e.g. sort the data or download the data), a request will be sent to java and after data processing the .jsp page will be refreshed and loaded again(of cause after sorting it should be refreshed). But I just found that if I download a data with the following code, the refreshing will be interrupted:

OutputStream out = response.getOutputStream(); // response is HttpServletResponse
doSomeOutput(out); // Just write something into OutputStream

out.flush(); // **PAY ATTENTION**. The refreshing is interrupted here!
out.close();

When I was debugging, the page was keeping loading until the third line. And then the page was not refreshed and the data was download.

I hope you can understand what I'm talking about:(

So now I have 2 questions: 1. How can I let the process keep working after out.flush();? 2. In my task I need the same behavior(the process is interrupted) in some other modules, but there's nothing to be download. So how can I interrupt the process besides out.flush();?

Thank you guys!!




Aucun commentaire:

Enregistrer un commentaire