no response from HttpGet client.execute(request) after initial login was successful
<p>I'm trying to log into <a href="http://sef.imapp.com/ilinks/search" rel="nofollow">this site</a> and collect some data.
I removed the username and password from the code i shared below, but when it takes the first url and password and runs i get a response showing me that the login was successful, however after saving the cookies and trying to run the second link with the query for the site it just hangs. no errors and no response. I played for hours but just cant get it. Its getting stuck at the <code>client.execute(request)</code> thats running with this link (http :// sef.imapp. com/ilinks/property?upin=US120860131120280120&amp;report=comps&amp;distance=0.5)</p>

<p>I copied the code from <a href="http://www.mkyong.com/java/apache-httpclient-examples/" rel="nofollow">http://www.mkyong.com/java/apache-httpclient-examples/</a> (Part 3) and made changes until i got the response html page showing logged in, but I just cant run the query url.</p>

<p>I appreciate any help to be explained in detail.
Thank you.</p>

<pre><code>package connectors;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.CookieHandler;
import java.net.CookieManager;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class HttpCilentExampleToMls {

  private String cookies;
  private HttpClient client = HttpClientBuilder.create().build();
  private final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.36 Safari/537.36";

  public static void main(String[] args) throws Exception {

    //Login page Changed from google address
    String url = "http://sef.imapp.com/ilinks/search";
    //Search page Changed from gmail address
    String mlsUrl = "http://sef.imapp.com/ilinks/property?upin=US120860131120280120&amp;report=comps&amp;distance=0.5";

    // make sure cookies is turn on
    CookieHandler.setDefault(new CookieManager());

    HttpCilentExampleToMls http = new HttpCilentExampleToMls();

    String page = http.GetPageContent(url);

    List&lt;NameValuePair&gt; postParams = 
                // Changed from "Username" and "Password"
               http.getFormParams(page, "Username","Password");

    http.sendPost(url, postParams);
    String result = http.GetPageContent(mlsUrl);
  }

  private void sendPost(String url, List&lt;NameValuePair&gt; postParams) 
        throws Exception {

    HttpPost post = new HttpPost(url);

    // add header
    post.setHeader("Host", "sef.imapp.com");
    post.setHeader("User-Agent", USER_AGENT);
    post.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
    post.setHeader("Accept-Language", "en-US,en;q=0.8");
    post.setHeader("Cookie", getCookies());
    post.setHeader("Connection", "Keep-Alive");
    post.setHeader("Referer", "http://sef.imapp.com/ilinks/login?logout=true");
    post.setHeader("Content-Type", "application/x-www-form-urlencoded");

    post.setEntity(new UrlEncodedFormEntity(postParams));

    HttpResponse response = client.execute(post);

    int responseCode = response.getStatusLine().getStatusCode();

    System.out.println("\nSending 'POST' request to URL : " + url);
    System.out.println("Post parameters : " + postParams);
    System.out.println("Response Code : " + responseCode);

    BufferedReader rd = new BufferedReader(
                new InputStreamReader(response.getEntity().getContent()));

    StringBuffer result = new StringBuffer();
    String line = "";
    while ((line = rd.readLine()) != null) {
        result.append(line);
        System.err.println(line);
    }

    // System.out.println(result.toString());

  }

  private String GetPageContent(String url) throws Exception {

    HttpGet request = new HttpGet(url);

    request.setHeader("User-Agent", USER_AGENT);
    request.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
    request.setHeader("Accept-Language", "en-US,en;q=0.8");
    HttpResponse response = client.execute(request);
    int responseCode = response.getStatusLine().getStatusCode();

    System.out.println("\nSending 'GET' request to URL : " + url);
    System.out.println("Response Code : " + responseCode);
    BufferedReader rd = new BufferedReader(
                new InputStreamReader(response.getEntity().getContent()));

    StringBuffer result = new StringBuffer();
    String line = "";
    while ((line = rd.readLine()) != null) {
        result.append(line);
    }
    // set cookies
    setCookies(response.getFirstHeader("Set-Cookie") == null ? "" : 
                     response.getFirstHeader("Set-Cookie").toString());
    return result.toString();
  }

  public List&lt;NameValuePair&gt; getFormParams(
             String html, String username, String password)
            throws UnsupportedEncodingException {

    System.out.println("Extracting form's data...");

    Document doc = Jsoup.parse(html);

    // Google form id
    Element loginform = doc.getElementById("standardLogin");
    Elements inputElements = loginform.getElementsByTag("input");


    List&lt;NameValuePair&gt; paramList = new ArrayList&lt;NameValuePair&gt;();

    for (Element inputElement : inputElements) {
        String key = inputElement.attr("name");
        String value = inputElement.attr("value");

        if (key.equals("user"))
            value = username;
        else if (key.equals("passwd"))
            value = password;

        paramList.add(new BasicNameValuePair(key, value));

    }

    return paramList;
  }

  public String getCookies() {
    return cookies;
  }

  public void setCookies(String cookies) {
    this.cookies = cookies;
  }

}
</code></pre>