Reputation: 829
I tried this Java Tip, but was unsuccessful. And by unsuccessful, I mean that the response I read back was the same exact page.
Here's a partial screenshot of the initial page -
As you can see, I'm trying to fill out the User Name and Password / Passcode fields. This will allow me to access other pages of interest. If it helps, here's a snippet of the form tag -
<form method="post" action="platform.cgi">
From the action attribute, I surmised that on a post, it would execute the platform.cgi script. Is this correct? Also, as for the Login button, it invokes a javascript method (i.e. loginValidate()
) -
<input type="submit" value="Login" name="umi.loginAuth" class="b0" title="Login" onclick="return loginValidate ()">
Also, here's a snippet of the two text fields, if that helps as well -
<input type="text" name="web0x120010" id="txtUserName" size="26" class="txtbox" maxlength="31">
<input type="password" name="web0x120011" id="txtPwd" size="26" class="txtbox" maxlength="64">
When I filled out the content as in the example, I used txtUserName
and txtPwd
, but that did not work. Any ideas or other resources that may help me?
If this isn't clear enough, please let me know - Thanks!
Upvotes: 1
Views: 3464
Reputation: 28865
Post with the names (web0x120010
and web0x120011
), not the ids of the input boxes and post the umi.loginAuth=Login
key-value pair too. If it doesn't help, install the HttpFox Firefox extension and record a normal login request and check the post parameters in the log.
According to http://stupidunixtricks.blogspot.com/2010_10_01_archive.html, you should take care about cookies too.
Upvotes: 2
Reputation: 17893
If your problem is the post some data and get into the site, then I would advice you to use common-http-client library which is essentially created for these type of problems. A typical way to invoke a post method to a site is as follows (from from Here)
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://vogellac2dm.appspot.com/register");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("registrationid",
"123456789"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
It becomes very convenient to you , You don't have to manage session as HttClient does it for you. This is important to access the subsequent pages after login, provided you use the same HttpClient instance.
Upvotes: 4