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
-- 
View this message in context: 
http://old.nabble.com/How-To-Retrieve-xml-dump-content-after-form-login-is-done-tp26702150p26702150.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