Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

HttpUrlConnection: Login works only for first page

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, everyone

I have a rather vexing problem:
My current project is a web agent that is supposed to log into a website, do stuff, and log off again.
Now, I managed to download the login page and I know I managed to login, because I can download the next page.
But then, if I try to "do stuff", that is, if I try to download the next page, I get a page that basically says "You're already logged in".
I tried this with the page that the web agent will work on, and since it didn't work, I tried it on our web site. But still the same problem:

1. I download the login page (which is not strictly necessary)
2. I send the login data and receive the first "logged-in" page
3. I try to download the next page and get our page that tells me that I'm already logged in

That is a major problem, because that keeps me from logging off properly.

I include both the Java code and a log file from Firefox's LiveHTTP module.
And now for some code:



Just in case anybody is wondering, this is what the LiveHTTP module for the FireFox logs when I log in "manually"

----------------------------------------------------------
http://www.cultuzz.com/index.php

GET /index.php HTTP/1.1
Host: www.cultuzz.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-DE; rv:1.7.5) Gecko/20041122 Firefox/1.0
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

HTTP/1.x 200 OK
Date: Thu, 01 Dec 2005 09:46:40 GMT
Server: Apache/1.3.26 (Linux/SuSE) mod_ssl/2.8.10 OpenSSL/0.9.6g PHP/4.3.3
X-Powered-By: PHP/4.3.3
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
----------------------------------------------------------
https://albatros.cultuzz.de/service/index.php

POST /service/index.php HTTP/1.1
Host: albatros.cultuzz.de
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-DE; rv:1.7.5) Gecko/20041122 Firefox/1.0
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.cultuzz.com/index.php
Cookie: PHPSESSID=ef95c17d3d442f70769e7be9bdbd40dd
Content-Type: application/x-www-form-urlencoded
Content-Length: 97
benutzer_kennung=XXXXX&benutzer_passwort=YYYYY&aktion=login&aktion=login&sprach_id_webseite=1
HTTP/1.x 200 OK
Date: Thu, 01 Dec 2005 09:46:43 GMT
Server: Apache/1.3.26 (Linux/SuSE) mod_ssl/2.8.10 OpenSSL/0.9.6g PHP/4.3.3
X-Powered-By: PHP/4.3.3
Set-Cookie: PHPSESSID=ef95c17d3d442f70769e7be9bdbd40dd; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
----------------------------------------------------------
https://albatros.cultuzz.de/service/_template.php //... snip

GET /service/_template.php //... snip
Host: albatros.cultuzz.de
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-DE; rv:1.7.5) Gecko/20041122 Firefox/1.0
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: https://albatros.cultuzz.de/service/index.php
Cookie: PHPSESSID=ef95c17d3d442f70769e7be9bdbd40dd

HTTP/1.x 200 OK
Date: Thu, 01 Dec 2005 09:46:47 GMT
Server: Apache/1.3.26 (Linux/SuSE) mod_ssl/2.8.10 OpenSSL/0.9.6g PHP/4.3.3
X-Powered-By: PHP/4.3.3
Set-Cookie: PHPSESSID=ef95c17d3d442f70769e7be9bdbd40dd; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
----------------------------------------------------------
https://albatros.cultuzz.de/service/index.php?aktion=logout&username=

GET /service/index.php?aktion=logout&username= HTTP/1.1
Host: albatros.cultuzz.de
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-DE; rv:1.7.5) Gecko/20041122 Firefox/1.0
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: https://albatros.cultuzz.de/service/_template.php //... snip
Cookie: PHPSESSID=ef95c17d3d442f70769e7be9bdbd40dd

HTTP/1.x 302 Found
Date: Thu, 01 Dec 2005 09:46:51 GMT
Server: Apache/1.3.26 (Linux/SuSE) mod_ssl/2.8.10 OpenSSL/0.9.6g PHP/4.3.3
X-Powered-By: PHP/4.3.3
Set-Cookie: PHPSESSID=ef95c17d3d442f70769e7be9bdbd40dd; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: http://www.cultuzz.com/index.php?meldung=
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
----------------------------------------------------------
http://www.cultuzz.com/index.php?meldung=

GET /index.php?meldung= HTTP/1.1
Host: www.cultuzz.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-DE; rv:1.7.5) Gecko/20041122 Firefox/1.0
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

HTTP/1.x 200 OK
Date: Thu, 01 Dec 2005 09:46:51 GMT
Server: Apache/1.3.26 (Linux/SuSE) mod_ssl/2.8.10 OpenSSL/0.9.6g PHP/4.3.3
X-Powered-By: PHP/4.3.3
Keep-Alive: timeout=15, max=97
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
----------------------------------------------------------
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic