Nej jeg tror ikke at jeg bliver logget ind.
Jeg kopirer lige hele min kode ind, hvis det kan være en hjælp. Jeg har faktisk bare fulgt hvad de har gjort her (og ændret det til https):
http://www.dreamincode.net/forums/blog/114/entry-2715-login-to-a-website-from-java/Nå men min kode er:
public class webLogin {
private URL URLObject;
private HttpsURLConnection connect;
public webLogin() throws IOException {
try {
URLObject = new URL( "
https://fronter.com/eamv/" );
connect = (HttpsURLConnection) URLObject.openConnection();
connect.setDoOutput( true );
connect.setDoInput( true );
connect.setRequestMethod( "POST" );
}
catch ( MalformedURLException e ) {
e.printStackTrace();
}
try {
// Create a buffered writer to the URLConnection's output stream and write
// our forms parameters.
String username = URLEncoder.encode("minBruger");
String password = URLEncoder.encode("minKode");
String newLang = URLEncoder.encode("dk");
BufferedWriter writer = new BufferedWriter( new OutputStreamWriter( connect.getOutputStream() ) );
writer.write( "username="+ username +"&password="+ password +"&newLang="+ newLang +"&submit=submit" );
writer.close();
System.out.println("Resp Code:"+connect.getResponseCode());
System.out.println("Resp Message:"+ connect.getResponseMessage());
// Now establish a buffered reader to read the URLConnection's input
// stream.
BufferedReader reader = new BufferedReader( new InputStreamReader( connect.getInputStream() ) );
String lineRead = "";
// Read all available lines of data from the URL and print them to screen.
while ( ( lineRead = reader.readLine() ) != null ) {
System.out.println( lineRead );
}
reader.close();
Runtime.getRuntime().exec( "C:\\Programmer\\Opera\\opera.exe" );
Thread.sleep( 6000 ); // Venter på at opera åbner
Runtime.getRuntime().exec( "cmd.exe /c start
http://fronter.com/eamv/main.phtml" );
}
catch ( Exception ex ) {
System.out.println( "There was an error reading or writing to the URL: " + ex.getMessage() );
}
}
}