Hello Roland,

When I do the same thing with browser after I logged in,here are the steps:

1)click on the link to get the form page(GetMethod in my loop)
2)Fill out the form and post data (PostMethod in my loop)
3)then it transfer me,open my library page, which shows my current 
records.(Redirect).

I did this 4-5 times, and all my records were there..so I did not have any 
problem with the browser...

And, in my code, I am doing the steps that I mentioned above i n my loop as 
belove:

for(int i=0;i<size;i++)
{

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();                
}

do you have any idea what I am doing wrong? Can you please help me?

thank you so much...

--teo


Roland Weber <[EMAIL PROTECTED]> wrote: 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




                
---------------------------------
 
 What are the most popular cars? Find out at Yahoo! Autos 

Reply via email to