title: How should I resolve java.lang.IllegalArgumentException: protocol = https host = null Exception?
body: <p>I am working on a SSL client server program and I have to reuse the following method.</p>
  
  <pre><code>private boolean postMessage(String message){
      try{ 
           String serverURLS = getRecipientURL(message);
  
           serverURLS = "https:\\\\abc.my.domain.com:55555\\update";
  
           if (serverURLS != null){
               serverURL = new URL(serverURLS);
           }
  
          HttpsURLConnection conn = (HttpsURLConnection)serverURL.openConnection();
  
          conn.setHostnameVerifier(new HostnameVerifier() { 
          public boolean verify(String arg0, SSLSession arg1) {
              return true;
          } 
          });
  
          conn.setDoOutput(true);
  
          OutputStream os = conn.getOutputStream();
  
          OutputStreamWriter wr = new OutputStreamWriter(os);
  
          wr.write(message);
  
          wr.flush();
  
          if (conn.getResponseCode() != HttpsURLConnection.HTTP_OK)
              return false;
          else
              return true;
  
      }
  </code></pre>
  
  <p>Here ServerURL is initialized as </p>
  
  <pre><code>private URL serverURL = null;
  </code></pre>
  
  <p>When I try to execute this method I get an exception at Line,</p>
  
  <blockquote>
    <p>OutputStream os = conn.getOutputStream();</p>
  </blockquote>
  
  <p>The exception is</p>
  
  <pre><code>java.lang.IllegalArgumentException: protocol = https host = null
  </code></pre>
  
  <p>What is the reason for this?</p>