Note that there are some explanatory texts on larger screens.

plurals
  1. POhttpclient redirect for newbies
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/3658721/httpclient-4-error-302-how-to-redirect">Httpclient 4, error 302. How to redirect?</a> </p> </blockquote> <p>I want to retrieve some information from my comcast account. Using examples on this site, I think I got pretty close. I am using firebug to see what to post, and I see that when I login I am being redirected. I don't understand how to follow the redirects. I have played with countless examples but just can't figure it out. I am new to programming and just not having any luck doing this. Here is my code. I make an initial login, then go to try to go to another URL which is where the redirects begin. Along the way, I see that I am acquiring lots of cookies, but not the important one s_lst. </p> <pre><code>HttpPost httpPost = new HttpPost("https://login.comcast.net/login"); List &lt;NameValuePair&gt; nvps = new ArrayList &lt;NameValuePair&gt;(); nvps.add(new BasicNameValuePair("continue", "https://login.comcast.net/account")); nvps.add(new BasicNameValuePair("deviceAuthn", "false")); nvps.add(new BasicNameValuePair("forceAuthn", "true")); nvps.add(new BasicNameValuePair("ipAddrAuthn", "false")); nvps.add(new BasicNameValuePair("lang", "en")); nvps.add(new BasicNameValuePair("passwd", "mypassword")); nvps.add(new BasicNameValuePair("r", "comcast.net")); nvps.add(new BasicNameValuePair("rm", "2")); nvps.add(new BasicNameValuePair("s", "ccentral-cima")); nvps.add(new BasicNameValuePair("user", "me")); httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); System.out.println("executing request " + httpPost.getURI()); // Create a response handler ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httpPost, responseHandler); String cima = StringUtils.substringBetween(responseBody, "cima.ticket\" value=\"", "\"&gt;"); System.out.println(cima); HttpPost httpPost2 = new HttpPost("https://customer.comcast.com/Secure/Home.aspx"); List &lt;NameValuePair&gt; nvps2 = new ArrayList &lt;NameValuePair&gt;(); nvps2.add(new BasicNameValuePair("cima.ticket", cima)); httpPost2.setEntity(new UrlEncodedFormEntity(nvps2, HTTP.UTF_8)); System.out.println("executing request " + httpPost2.getURI()); // Create a response handler ResponseHandler&lt;String&gt; responseHandler2 = new BasicResponseHandler(); String responseBody2 = httpclient.execute(httpPost2, responseHandler2); System.out.println(responseBody2); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload