Issue
when a client disconnects from a server request prematurely, does the server still carries out rest of the work?
specifically, in a Java Servlet doGet if I have the following code:
public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException { A(); //client disconnects after A(); B(); C(); } if client disconnects after A() is finished, would B and C still get executed?
Solution
It depends.
If during A()
(or any other method) you would attempt to send the response (using res
) back to the client, IOException
would be thrown. If not caught, it would terminate the servlet execution.
Otherwise the calculation would carry on and exit after C()
.
Answered By - mindas