What I want to do is to delay an HttpServletResponse.Why?
I set up some response.setHeader but then I want to wait a while after setting other values as the length of data to sendYou don't have to set th Content-Length header at alll. The container does it for you. You could have caused a problem by doing that.
and the content itself.Just write it when you're ready.
949658 wrote:You don't want the browser to be waiting for a response, the user experience is then that nothing is happening which will invite them to refresh the page, causing multiple requests to fire. Better is to treat this as a background job which can be started. The initial response to the client is then "okay, its been started" (or "something is already running!") and you provide an overview of running jobs which can be used to check the status. With some ajax magic you could even automate that without a need for the client to manually reload the job status page.
1. Basically what I want is my client will initiate a doGet request but at that time, the answer is not ready yet. So it should wait and check(in a while loop ?) the connection till a not NULL answer arrives.
2. You are right, I can just set the answer whenever it is ready. Though I am not sure how to suspend the client side till some content is on the connection.See 1).
I am not sure how to suspend the client side till some content is on the connection.That's what it does. You don't have to add anything at the server end. just write the response when you're ready. The client will block until it arrives. No action required on your part whatsoever.