Hi,
   I am trying to do a post to a secure site. First I am trying to get to a 
page using get method and that page contains a form with at least 20 
parameters. I am trying to post to that page. The status from that is 200 OK  
but it displays the same page. Do you see any error in the following code. 
 
    String url = "https://secure.mysite.com/mydir?param=value";;
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url);
PostMethod pMethod = new 
PostMethod("/path/mentioned/in/the/actionfield/of/the/form");
    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());
      }
      byte[] responseBody = method.getResponseBody();
      URI postURI = new URI("https","secure.mysite.com","/","");
   client.getHostConfiguration().setHost(postURI);
      NameValuePair[] params = {
    new NameValuePair("Day", "27")
    // Lot of other parameters
      };
      pMethod.setRequestBody(params);
      client.executeMethod(pMethod);
      System.out.println(pMethod.getStatusLine().toString());
      String postResponse = pMethod.getResponseBodyAsString();
      
    }.....
    ....
Thanks
-M
.


                
---------------------------------
 Start your day with Yahoo! - make it your home page 
__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to