response.getOutputStream.flush() throws ClientAbortException

   response.setHeader("Connection", "Close");
   try {

        OutputStream os = response.getOutputStream();
        byte[] bytes = new byte[2048];
        int count =;
        while (count > 0) {
            os.write(bytes, 0, count);
            count =;
        os.flush();   // this line throws ClientAbortException
    } catch (Exception e) {

    } finally {
        // Do I need to close os here

In what all situations, we will get the above error ClientAbortException: Connection reset

Note: Mine is a server program and my server sends RST signal to the clinet at that point while submitting the response.