You cannot tell for sure. It depends on how your servlet container is implemented.
When the user clicks Cancel, the browser should close the socket. Of course, this will be detected by the server, but regardless of whether the server ServletOutputStream "plumbed" directly has an OutputStream socket, it depends on the implementation. If this happens, an IOException will be raised the next time the servlet tries to write data.
If the output buffers of the containers are output, the servlet may just end up writing data and never know that something went wrong.
source share