I think I have seen a web page display part of the html response while the server is still returning information. Is there a way of coding your servlet so that for a given page part of the html response can be displayed before the servlet is done writting to the output stream?
At any point, you can do a out.flush() - that should send any characters currently in the output buffer. Of course, whether or not the browser display will show any activity depends on the browser and the HTML you are sending. I think a plain <p> paragraph will get displayed but if you are building a table the browser may wait until the table is finished to show it. Bill
Flushing the output buffer for the first time sends the HTTP headers. Since redirect involves setting a header line, if you do it after the headers have been sent you get a IllegalStateException. Bill
Another option is to create a task for the long running action.
Assign it an id.
The task writes its progress to a session variable keyed by that id.
Send the user to a page with that id as a parameter.
That page loads the progress from the session based on the id. The page reloads itself (using Javascript or a meta refresh tag) until the task is complete.