hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kim young ill <khi...@googlemail.com>
Subject Re: Submitting POST with x-www-form-encoded
Date Tue, 19 Jul 2011 22:35:08 GMT
On Tue, Jul 19, 2011 at 11:59 PM, Villemos, Gert
<gert.villemos@logica.com>wrote:

> I need to POST to a login form with the specification
>
>
> <form name="loginForm" METHOD="post" ACTION="/arsys/servlet/LoginServlet"
> enctype="x-www-form-encoded">
>
>
> For this I have to questions
>
> 1. I dont understand how the form action is specified. Is it specified
> (like the commons httpclient) as a NameValuePair such as
>
>   List<NameValuePair> formparams = new ArrayList<NameValuePair>();
>   formparams.add(new BasicNameValuePair("action", "loginForm"));
>
>
>
> 2. How can I encode as x-www-form-encoded''? I have tried
>
>  entity = new UrlEncodedFormEntity(formparams, "x-www-form-encoded");
>
> But get an exception.
>
>
> Think green - keep it on the screen.
>
> This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. It may contain proprietary material, confidential
> information and/or be subject to legal privilege. It should not be copied,
> disclosed to, retained or used by, any other party. If you are not an
> intended recipient then please promptly delete this e-mail and any
> attachment and all copies and inform the sender. Thank you.
>
>


try this:

HttpPost post = new HttpPost("http://..../arsys/servlet/LoginServlet")
List<NameValuePair> formparams = new ArrayList<NameValuePair>();
  formparams.add(new BasicNameValuePair("username", "john"));
formparams.add(new BasicNameValuePair("password", "secret"));

HttpEntity entity = new UrlEncodedFormEntity(formparams);
post.setEntity(entity);
post.execute()...

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message