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: [email protected]