HTTP is stateless, which means that after a client "gets" the data for it's request, the conneciton is closed. There's no open connection to a servlet unless you purposefully send JavaScript to the web browser to download "extra" information that you purposefully don't provide with the servlet. AKA the basis for all AJAX technologies.
Assuming that you are using a AJAX like setup, where the socket is being held open, it is not really possible to know if a socket is valid until you either successfully read from it or write to it. This is because of the standard upon which sockets were implemented. Basically a socket might refer to two different items, the entire connection or the "on my box" side of the connection. The part that you actually interface with maintains an open state until a reason to change the state occurs.
That reason to change the state might be an explicit message from the remote machine, but due to network outages, power outages, machine crashes, or just plain old congestion, an explicit close message can never be guaranteed. That means that until the socket is actually used successfully, you cannot assume that the connection to the remote machine actually is working. You must either read from the socket or write to the socket to know the connection is still valid. Since you cannot typically force a read from the socket (how do you get the other machine to talk to you?) you typically are forced to write to the socket. If the message cannot be delivered, the error will propagate up through the network stack and the socket will close.
So you can check socket state for "was it closed deliberately", but you cannot really know if you have a valid connection without writing something. If it is that critical, use a bit of the AJAX framework to maintain an open socket state (remember we have to defeat normal HTTP handling to keep a socket open anyway) and pump "do nothing" messages down the socket to verify it's connection status.
Perhaps this is on the mark, perhaps it has missed it. More information might guide this answer to a better solution for your needs.