hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <http-as...@dubioso.net>
Subject Re: help with httpclient methods please!!!!
Date Wed, 01 Feb 2006 03:21:16 GMT
Hi teo,

> Right after logged-in, I need to get my form page by using GetMethod, and
> then I need to use PostMethod to post my data.And, there is a redirection
> again, so I need to use GetMethod again. When I do this actually it works
> for submitting one record..but if I do this in a loop for posting more than
> one record, it just shows my last record in my library on the web site..it
> kind of ignores or does not submit successfully the preious records.

Or else each record overwrites the one sent previously. Try the same thing
with a browser. Make sure you replicate *every* request in your application.
Do you really use GetMethod for the form in the loop, or did you get the
form only once before entering the loop? Is there anything in the URL or
the posted data that could be a counter or transaction identifier which you
have to update? Try GetMethod on the main page or a status page in each
loop iteration.

hope that helps,
  Roland


> GetMethod getAddForm = new GetMethod(LOGON_SITE+"/add");
>                 status =  client.executeMethod(getAddForm);
> 
> PostMethod postAddForm = new PostMethod(LOGON_SITE+"/add");
>                 postAddForm.setRequestBody(ref);
>                 status = client.executeMethod(postAddForm);
> 
> locationHeader = postAddForm.getResponseHeader("location");
>                 postAddForm.releaseConnection();
>                 if (locationHeader != null) {
>                     redirectLocation = locationHeader.getValue();
>                     System.out.println("Redirect after posting:"
>                              + redirectLocation + "\n");
>                     GetMethod getRedirectPostForm = new GetMethod(
>                             redirectLocation);
>                     getRedirectPostForm.setFollowRedirects(true);
>                     status = client.executeMethod(getRedirectPostForm);
> getRedirectPostForm.releaseConnection();
>                 }

---------------------------------------------------------------------
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