title: Error: Target host must not be null, or set in parameters
body: <p>I am trying to send a string from one application to another. I would be returning a response which is a string.  Here, myhost.com/views is the 2nd application where I need to send the string value and get a response from it. But when I am trying to send it is not executing this code. Can someone please correct me where I am wrong?</p>
  
  <p>Below is the code I have written.  </p>
  
  <pre><code>  public static void sendData(String strval) throws IOException{ 
  String doSend="https://myhost.com/views?strval="+strval;
     HttpClient httpclient = new DefaultHttpClient();
       try {
           System.out.println("inside try");
           URIBuilder builder = new URIBuilder();
           System.out.println("builder="+builder);
  
           builder.setHost("myhost.com").setPath("/views");
           builder.addParameter("strval", strval); 
           System.out.println("add param,sethost,setpath complete");
  
           URI uri = builder.build();
           System.out.println("uri="+uri);
  
  
           HttpGet httpget = new HttpGet(uri); 
           System.out.println("httpGet"+httpget);
  
           HttpResponse response = httpclient.execute(httpget);
           System.out.println(response.getStatusLine().toString());
  
           if (response.getStatusLine().getStatusCode() == 200) {
              String responseText = EntityUtils.toString(response.getEntity());
              System.out.println("responseText="+responseText);
              httpclient.getConnectionManager().shutdown();
           } else {
             System.out.println("Server returned HTTP code "
                      + response.getStatusLine().getStatusCode());
           }
        } catch (java.net.URISyntaxException bad) {
           System.out.println("URI construction error: " + bad.toString());
        }
        catch(Exception e){ System.out.println("e.getMessage=&gt;"+e.getMessage());  }
  
      }
  </code></pre>
  
  <p>Code runs till and when I print the exceptions I see excep.getMessage() ->  </p>
  
  <pre><code>     java.lang.IllegalStateException: Target host must not be null, or set in parameters.
      at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:789)
      at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:414)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
  </code></pre>