I am doing a POST login. To do so I am using a combination of HTTPComponents (Apache) and native Java libraries.
//send the stuff
HttpResponse responder = httpclient.execute(poster);
System.out.println(responder.getStatusLine());
//The output of this is always 302 Found
String rawdata;
//Use Sun's stuff to connect to the account home page
URL website = new URL(HOME_PAGE);
URLConnection connect = website.openConnection();
//Read it using a BufferedReader
BufferedReader reader = new BufferedReader (new InputStreamReader (connect.getInputStream()));
while (!(rawdata = reader.readLine()).startsWith("<title>")) {}
System.out.println(rawdata);
My problem is that I will get a 302 Found code from the Post login and then attempt to connect to the homepage for the account (account/index.php). This works most of the time, but once in a while I receive the HTML for the login page with an error message (need to be logged in to access...). I have not be able to find a pattern to this.