Hi Jim
One thing you can try is logging in with a purposefully incorrect
username/password combo an check your response. This should give you
the login page but with an error message:
UserName and/or Password you entered are incorrect. Please update them
below.
If this is not the case, then the post is not handled correctly. I
suspect that the javascript that actually submits the form does
something with all those hidden fields before submission - otherwise
they are quite meaningless.
You could also try some browser plugin like liver http headers or
firebug (both for firefox) to see what is posted or you can
investigate the javascript that actually does the submit to see what
it does to all the hidden form fields.
Met Vriendelijke groet/Kind regards,
Ernst Nolte
Email: [email protected]
Website: http://www.synquad.nl
Office: Zwarteweg 6-D, 1412GD, Naarden
Tel: +31(0)35 698 11 55
Fax: +31(0)35 698 27 42
Mob: +31(0)6 813 287 75
On 5 Mar 2010, at 14:09, Langston, James wrote:
Hi Ernst,
Ok - digging at this a little more, it looks like this is the string
needed for
submitting.
file:///home/jim/Desktop/login.asp?username=****&pwd=****&login.x=&login
.y=&server_string=&url_string=&query_string=&form_string=
I have change my code to reflect those parameters:
List<NameValuePair> vals = new ArrayList<NameValuePair>();
vals.add(new BasicNameValuePair("username", "****"));
vals.add(new BasicNameValuePair("pwd", "****"));
vals.add(new BasicNameValuePair("login.x", ""));
vals.add(new BasicNameValuePair("login.y", ""));
vals.add(new BasicNameValuePair("server_string", ""));
vals.add(new BasicNameValuePair("url_string", ""));
vals.add(new BasicNameValuePair("query_string", ""));
vals.add(new BasicNameValuePair("form_string", ""));
but, the results are the same, any thoughts ?
Jim
////////////////////////////////////
Jim Langston
Technical Consultant
[email protected]
-----Original Message-----
From: Ernst Nolte [mailto:[email protected]]
Sent: Thursday, March 04, 2010 6:01 PM
To: HttpClient User Discussion
Subject: Re: responding to form login fields
On 4 Mar 2010, at 23:57, Oleg Kalnichevski wrote:
Ernst Nolte wrote:
Hi Jim
How do you create your HttpClient? I once had a similar problem
with trying to log into a server and kept being returned to the
login page - it was solved by reusing the same httpClient for all
subsequent requests of the same user session. (I must admit that I
still don't know exactly why this worked - but it did)
Because along with the HttpClient instance you also kept all cookies
stored in the cookie store associated with that instance.
That was what I thought so I set all cookies manually, but with no
success - I assume I did not do it correctly.
Oleg
Met Vriendelijke groet/Kind regards,
Ernst Nolte
Email: [email protected]
Website: http://www.synquad.nl
Office: Zwarteweg 6-D, 1412GD, Naarden
Tel: +31(0)35 698 11 55
Fax: +31(0)35 698 27 42
Mob: +31(0)6 813 287 75
On 4 Mar 2010, at 23:13, Langston, James wrote:
Hi Ernst,
After a couple of starts and stops. Yes, using 4.0.1 and
also tried 4.1alpha1 , after doing the post, w/ a username
and password, I do not see the next page, the response shows
just the initial page which has the login/passwords field, but
not the next page which is what I'm expecting to see.
any thoughts ? seems that I'm not posting the login/password.
Jim
HttpPost post = new
HttpPost("http://www.gomeznetworks.com/login.asp");
List<NameValuePair> vals = new ArrayList<NameValuePair>();
vals.add(new BasicNameValuePair("username", "****"));
vals.add(new BasicNameValuePair("pwd", "****"));
post.setEntity(new UrlEncodedFormEntity(vals, HTTP.UTF_8));
HttpResponse response2 = client.execute(post);
HttpEntity entity2 = response2.getEntity() ;
System.out.println("Login form get: " +
response2.getStatusLine());
System.out.println("Response content length: "
+ entity2.getContentLength());
if (entity2 != null) {
System.out.println(EntityUtils.toString(entity2));
entity2.consumeContent();
}
Jim
/////////////////////////////////////
Jim Langston
Technical Consultant
[email protected]
-----Original Message-----
From: Ernst Nolte [mailto:[email protected]]
Sent: Thursday, March 04, 2010 8:45 AM
To: HttpClient User Discussion
Subject: Re: responding to form login fields
Hi Jim
I assume you use HttpClient v4?
If you look at the form action attribute in the page you will see
this:
<form action="login.asp" method="post" id="form1" name="form1">
So you need to post the parameters to this url:
http://www.gomeznetworks.com/login.asp
and set the fields like this:
HttpPost post = new HttpPost(url);
List<NameValuePair> vals = new ArrayList<NameValuePair>();
vals.add(new BasicNameValuePair("username", "you"));
vals.add(new BasicNameValuePair("pwd", "passwd"));
post.setEntity(new UrlEncodedFormEntity(vals, HTTP.UTF_8));
and now execute it.
as far as the input type image is concerned, I think the onclick
event
of image is captured bij Javascript event attachment and in that
handler the form is posted, but I did not bother to verify that.
Met Vriendelijke groet/Kind regards,
Ernst Nolte
Email: [email protected]
Website: http://www.synquad.nl
Office: Zwarteweg 6-D, 1412GD, Naarden
Tel: +31(0)35 698 11 55
Fax: +31(0)35 698 27 42
Mob: +31(0)6 813 287 75
On 4 Mar 2010, at 13:55, Langston, James wrote:
Hi all,
After tons of look up - I haven't been able to find a good
example of
being able
to correctly respond to a login form that is using an
type="image" to
initiate the login
process. The fields in the html are:
<td>
Username:<br>
<input
type="text" size="30" maxlength="60" name="username"><br>
Password:<br>
<input
type="password" size="30" maxlength="60" name="pwd">
<input
type="image" src="images/buttons/submit_gray.gif
<view-source:http://www.gomeznetworks.com/images/buttons/submit_gray.gif
" name="login" align="absmiddle">
<input
type="hidden" name="server_string" value="">
<input
type="hidden" name="url_string" value="">
<input
type="hidden" name="query_string" value="">
<input
type="hidden" name="form_string" value="">
</td>
and I need to respond to username, password and login. I do not
understand how to create the NameValuePair to respond to the
image in order to submit the login and move to the next page in
the
sequence.
Any thoughts, hints ?
Thanks,
Jim
//////////////////////////////////////////
Jim Langston
Technical Consultant
[email protected]
The contents of this e-mail are intended for the named addressee
only. It contains information that may be confidential. Unless you
are the named addressee or an authorized designee, you may not
copy
or use it, or disclose it to anyone else. If you received it in
error please notify us immediately and then destroy it.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: httpclient-users-
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]