Hey olegk,

I am not quite sure on how to retrieve the wire log and display it.  However
I have found the answer to my prior post but now I have a new problem.  I
have found how to retrieve the source code by using a ResponseHandler. 
However the source code i get from this ResponseHandler returns to me the
code of the login page.  Either I am not getting redirected properly or I am
taking the response from before I log in.  Any thoughts on this matter would
be much appreciated!

The code for my ResponseHandler:
                
ResponseHandler<String> handler = new BasicResponseHandler();
String r = client.execute(httpGet, handler);
System.out.println(r);

-Dennis


olegk wrote:
> 
> Dennis Ryu wrote:
>> Hi,
>> 
>> I am trying to retrieve xml dump content from a page.  There is a login
>> page
>> prior to reaching the page with the xml dump content.  I have based my
>> code
>> off of the form-logon example in order to get past the login page and
>> then
>> redirected to the new page containing the dump.  However I am not sure of
>> which method to call on which object in order to procure the data I
>> needed. 
>> Nor am I certain if I am getting redirected to the proper page.  I have
>> included my code below and any help would be great! Thanks in advance!
>> 
>>                 DefaultHttpClient client = new DefaultHttpClient();
>>              HttpGet httpGet = new HttpGet("my website (removed for security
>> purposes)");
>>              HttpResponse response = client.execute(httpGet);
>>              HttpEntity entity = response.getEntity();
>>              System.out.println("Login form get: " + 
>> response.getStatusLine());
>>              if (entity != null)
>>              {
>>                      entity.consumeContent();
>>              }
>>              System.out.println("Initial set of cookies:");
>>              List<Cookie> cookies = client.getCookieStore().getCookies();
>>              if (cookies.isEmpty())
>>              {
>>                      System.out.println("None");
>>              }
>>              else
>>              {
>>                      for (int x = 0; x < cookies.size(); x++)
>>                      {
>>                              System.out.println("- " + 
>> cookies.get(x).toString());
>>                      }
>>              }
>>              
>>              HttpPost httpPost = new HttpPost("my website (removed for 
>> security
>> purposes)");
>>              List<NameValuePair> nvps = new ArrayList<NameValuePair>();
>>              nvps.add(new BasicNameValuePair("IDToken1", "user id (removed 
>> for
>> security
>> purposes)"));
>>              nvps.add(new BasicNameValuePair("IDToken2", "password (removed 
>> for
>> security purposes)"));
>>              httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
>>              
>>              response = client.execute(httpPost);
>>              entity = response.getEntity();
>>              
>>              System.out.println("Login form get: " + 
>> response.getStatusLine());
>>              
>>              if (entity != null)
>>              {
>>                      entity.consumeContent();
>>              }
>>              System.out.println("Post logon cookies:");
>>              cookies = client.getCookieStore().getCookies();
>>              if (cookies.isEmpty())
>>              {
>>                      System.out.println("None");
>>              }
>>              else
>>              {
>>                      for (int x = 0; x < cookies.size(); x++)
>>                      {
>>                              System.out.println("- " + 
>> cookies.get(x).toString());
>>                      }
>>              }
>> 
>> When running this script I get the following:
>> 
>> Login form get: HTTP/1.1 200 OK
>> Initial set of cookies:
>> - [version: 0][name: PHPSESSID][value:
>> 3295561e35cdf71b587b545f8148136a][domain: testbed.toomuchmedia.com][path:
>> /][expiry: null]
>> Login form get: HTTP/1.1 302 Found
>> Post logon cookies:
>> - [version: 0][name: PHPSESSID][value:
>> 3295561e35cdf71b587b545f8148136a][domain: testbed.toomuchmedia.com][path:
>> /][expiry: null]
>> 
>> From a bit of research I know that "302 Found" means that I have been
>> redirected so I am assuming that I have gone through to the right page
>> with
>> the correct data.  I am just unsure of how to extract the dump which I
>> would
>> normally view by viewing the source code while on that page.  Thanks
>> again!
>> 
>> -Dennis
> 
> Dennis,
> 
> I find it strange that HttpClient did not handle that redirect 
> automatically. Can you post a wire log of the session?
> 
> http://hc.apache.org/httpcomponents-client/logging.html
> 
> Oleg
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-To-Retrieve-xml-dump-content-after-form-login-is-done-tp26702150p26748902.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to