hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Srinivas Chamarthi" <srinivas.chamar...@gmail.com>
Subject getting null form in struts when form data is posted using http client
Date Mon, 21 Apr 2008 11:50:00 GMT
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();
       }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message