You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Srinivas Chamarthi <sr...@gmail.com> on 2008/04/21 13:50:00 UTC

getting null form in struts when form data is posted using http client

Hi,

I am using the following code to access struts based web application. But
when the request passes to the application in execute method, the form is
coming as null. Could you please let me know why am I getting null form ?
Appreciate any help in this regard.


        HttpClient client = new HttpClient();

        PostMethod method = new PostMethod("
http://localhost:8080/TMC/home.do");

        NameValuePair[] nv = new NameValuePair[3];
        nv[0] = new NameValuePair("siteUser","admin");
        nv[1] = new NameValuePair("sitePassword","test");
        nv[2] = new NameValuePair("timeZone","PST");

        method.setRequestBody(nv);

        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
                new DefaultHttpMethodRetryHandler(3, false));

        try {
               int statusCode = client.executeMethod(method);

               if (statusCode != HttpStatus.SC_OK) {
                    System.err.println("Method failed: " +
method.getStatusLine());
               }

            // Read the response body.
              byte[] responseBody = method.getResponseBody();
       }