bhadu wrote:
> Look at my code...............First servlet...........
> 
> 
>            String urlString = "http://localhost:8787//testone//MyServlet";;
>               
>                       
>                       HttpClient client = new HttpClient();
>               PostMethod postMethod = new PostMethod(urlString);
>               post(postMethod);

So here you are setting the entity of the POST method
to a multipart entity.

>               client.getParams().setParameter("http.useragent", "My Browser");
>               postMethod.addParameter("test","testvalue");
>               NameValuePair[] nm = {new NameValuePair("test","test")};
>               postMethod.setRequestBody(nm);

And here you replace that with "test=test".

An entity _is_ the request body. You can have only one.

cheers,
  Roland

>               int statusCode1 = client.executeMethod(postMethod);
>               System.out.println(" status >>> "+statusCode1);
>               System.out.println("statusLine>>>" + 
> postMethod.getStatusLine());
>               postMethod.releaseConnection();
>               
> 
>       }
> 
>       private void post(PostMethod postMethod) throws FileNotFoundException
>       {
>                File f = new File("C:\\error.txt");
>                System.out.println("file exit = "+f.exists());
>               Part[] parts = {
>                 new FilePart(f.getName(), f)
>             };
>       
> postMethod.addRequestHeader("Content-type","multipart/form-data;boundary="+f.length());
>               postMethod.addRequestHeader("content-disposition","form-data;
> name="+f.getName());
>               postMethod.setRequestEntity(
>                 new MultipartRequestEntity(parts, postMethod.getParams())
>                 );
>       }
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to