Hi!

I am trying to log in on the website www.nordnet.dk. The website has a login-form (with the redirected address https://www.nordnet.se/tux/lang/login/login.pl) which I try to fill out using the following code:

HttpClient client = new HttpClient();
PostMethod pm = new PostMethod("http://www.nordnet.dk/";);
NameValuePair action   = new NameValuePair("action", "myForm");
NameValuePair url = new NameValuePair("url", "https://www.nordnet.se/tux/lang/login/login.pl";);
NameValuePair userid   = new NameValuePair("a1", "my-userid");
NameValuePair password = new NameValuePair("a2", "my-password");
pm.setRequestBody(new NameValuePair[] {action, url, userid, password});

try {
   int statusCode = client.executeMethod(pm);
   if (statusCode != HttpStatus.SC_OK) {
       System.err.println("Method failed: " + pm.getStatusLine());
   }
   System.out.println("Login form post: " + pm.getStatusLine().toString());
} catch (HttpException e) {
   System.err.println("Fatal protocol violation: " + e.getMessage());
   e.printStackTrace();
} catch (IOException e) {
   System.err.println("Fatal transport error: " + e.getMessage());
   e.printStackTrace();
} finally {
   pm.releaseConnection();
}

- which returns a "Method failed: HTTP/1.1 405 Method Not Allowed"-error.

A little simplified I skip the website-address and access the https-login-address directly:

PostMethod pm = new PostMethod("https://www.nordnet.se/tux/lang/login/login.pl";);
NameValuePair userid   = new NameValuePair("a1", "my-userid");
NameValuePair password = new NameValuePair("a2", "my-password");
pm.setRequestBody(new NameValuePair[] {userid, password});

try {
     .. (same code as above) ..
   }

- and this works fine.

Why doesn't the first piece of code work?


Regards,
Jesper



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to