title: Obtain response code for HTTPS connection
body: <p>I am trying to check weather my jboss server is up or not or <strong>simply url is reachable or not</strong>. I am achieving same using responseCode i.e. <code>200</code> for OK. I am able to do for HTTP but fails for HTTPS.
    So I want the responseCode for HTTPS.</p>
  
  <p>I am using below code </p>
  
  <pre><code>        HttpURLConnection urlCon = null;
          URL url = new URL("http://localhost:8080/abc");
          urlCon = (HttpURLConnection) url.openConnection();
          System.out.println(urlCon.getResponseCode());
          if(urlCon.getResponseCode() == 200)
          {
              System.out.println("Server is up");
          }
  </code></pre>
  
  <p>works fine for <code>HTTP</code> but when I am trying same for <code>HTTPS</code> It gives connection refuse or SSLhandshakeException</p>
  
  <pre><code>javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:882)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1215)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1199)
      at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
      at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)
      at com.de.base.tools.Sample.main(Sample.java:23)
  Caused by: java.io.EOFException: SSL peer shut down incorrectly
      at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:462)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:863)
      ... 9 more
  </code></pre>
  
  <p>I have tried <code>HttpURLConnection</code> to <code>HttpsURLConnection</code> but gives same </p>
  
  <p>anybody know how to get <code>responceCode()</code> for <code>HTTPS</code></p>
  
  <p>Thanks.</p>