The isClientConnected method of the Response class returns a Boolean that indicates whether the client has disconnected.
public boolean isClientConnected();