Hello Meghana, System.out.flush() has nothing to do with it. Either you print the value of the variable you are interested in, or you print the wrong variable.
Please use the wire log to check what is received: http://jakarta.apache.org/commons/httpclient/logging.html hope that helps, Roland Meghana <[EMAIL PROTECTED]> 27.07.2005 14:43 Please respond to "HttpClient User Discussion" To HttpClient User Discussion <[email protected]> cc Subject Re: Post to a secure site Roland, Thanks for your response. So do I need to flush the some where in order to get the correct value in the "postResponse"? I used System.out.flush() in vain. It displays the same page. Not sure where I am erring. Thanks for you help -M --- Roland Weber <[EMAIL PROTECTED]> wrote: > Hi Meghana, > > on first glance, the code looks OK. You are aware > that the document from the GET request is stored > as a byte array in "responseBody", while the one > from the POST request is stored as a string in > "postResponse"? > Since you "display" the same page twice, have you > checked that the display method actually tries to > display "postResponse" rather than "responseBody" > on the second occasion? Last time something like > this happened in my code, it was caused by some > copy-and-paste bug in the debug output statements. > > hope that helps, > Roland > > > > > Meghana <[EMAIL PROTECTED]> > 27.07.2005 04:57 > Please respond to > "HttpClient User Discussion" > > > To > [email protected] > cc > > Subject > Post to a secure site > > > > > > > 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 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
