title: HttpClient follow redirect
body: <p>I am currently working on little project. The aim of the project is to log in to a website and  get/handle the information on the site. Moreover, I would like to open some links and search through them as well.</p>
  
  <p>The server side looks like this: </p>
  
  <p>You need to login to a php site. When sucessfully login you get a session and will be redirected to foo.username.bar.php (changed). </p>
  
  <p>With this code:</p>
  
  <pre><code>BufferedReader in = null;
      String data = null;
      try {
          List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
          nameValuePairs.add(new BasicNameValuePair("username",  user));
          nameValuePairs.add(new BasicNameValuePair("passwort", pass));
  
          HttpClient client = new DefaultHttpClient();
          HttpPost request = new HttpPost(website);
          request.setEntity(new UrlEncodedFormEntity(nameValuePairs));
          HttpResponse response = client.execute(request);
          in = new BufferedReader(new InputStreamReader(response.getEntity()
                  .getContent()));
          StringBuffer sb = new StringBuffer("");
          String l = "";
          String nl = System.getProperty("line.separator");
          while ((l = in.readLine()) != null) {
              sb.append(l + nl);
          }
          in.close();
          data = sb.toString();
          return data;
      } finally {
  
          if (in == null) {
              try {
                  in.close();
                  return "ERROR";
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>
  
  <p>I sucessfully logged into the website. However, I can only see the page source of the php user confirmation site which tells me that I was sucessfully logged in and will be redirected. </p>
  
  <p>Now I actually want to see the page source where I was redirected too and keep the connection in order to open some more links on that page.</p>
  
  <p>Do you guys have an Idea how I can solve this?</p>