hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Http Post method dosn't work
Date Sat, 10 Nov 2007 11:20:20 GMT
You probably need to include the hidden __VIEWSTATE field.

Capture HTTP requests generated by the browser using a
traffic analyzer or a proxy, customize HttpClient to generate identical
(compatible) requests.

See also the very useful:
http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners

On 10/11/2007, divakarasrinivas <divakarasrinivas@gmail.com> wrote:
>
> Hi..
>
> In the  Mcdonald's webpage  http://go.mappoint.net/mcdonaldsx/PrxInput.aspx,
> I gave 91362 as zip code in the textbox,and got the Restaurant locations.
> I would like do the same thing using java application.Iam using http post
> method,but it is not posting the data.
>
> The code Is like this:
>
>
> import org.apache.commons.httpclient.HttpClient;
> import org.apache.commons.httpclient.HttpStatus;
> import org.apache.commons.httpclient.methods.PostMethod;
> import java.io.BufferedReader;
> import java.io.InputStreamReader;
>
> public class PostMethodExample
> {
>
>  public static void main(String args[])
>  {
>
>    HttpClient client = new HttpClient();
>    client.getParams().setParameter("http.useragent", "Test Client");
>
>    BufferedReader br = null;
>
>    PostMethod method = new
> PostMethod("http://go.mappoint.net/mcdonaldsx/PrxInput.aspx");
>    method.addParameter("controlAddressBasic:textfield", "91362");
>
>
>
>    try
>    {
>      int returnCode = client.executeMethod(method);
>
>      if(returnCode == HttpStatus.SC_NOT_IMPLEMENTED)
>      {
>               System.err.println("The Post method is not implemented by
> this URI");
>               method.getResponseBodyAsString();
>      }
>      else
>      {
>        br = new BufferedReader(new
> InputStreamReader(method.getResponseBodyAsStream()));
>        String readLine;
>        while(((readLine = br.readLine()) != null))
>        {
>          System.err.println(readLine);
>        }
>      }
>    }
>    catch (Exception e)
>    {
>      System.err.println(e);
>    }
>    finally
>    {
>      method.releaseConnection();
>      if(br != null)
>          try { br.close(); }
>          catch (Exception fe) {}
>    }
>
>  }
> }
>
> Iam getting the same page as output.It Means it is not posting the data.
>
> But I need to get the restaurant addresses with that Zip code.
>
> Anybody please solve this problem..
>
> Regards,
> DivakaraSrinivas
>
> --
> View this message in context: http://www.nabble.com/Http-Post-method-dosn%27t-work-tf4782104.html#a13680850
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message