Hello,
The post method needs a redirection. It shows the url in DEBUG but response gives the same html page & not the new redirect one. Here is the POST method: [code] public String POST(String url, NameValuePair[] data) { String res = ""; String URL = ymailSinupUrl + "&_ylt=A9FJpMBjCkRHERcBDgCZ2PAI"; NameValuePair formData[] = { new NameValuePair("u", _dsh), new NameValuePair("t", _t1), new NameValuePair("preferredcontent", this.preferLang), new NameValuePair("firstname", FirstName), new NameValuePair("secondname", LastName), new NameValuePair("gender", this.gender), new NameValuePair("mm", this.bMm), new NameValuePair("dd", bDate), new NameValuePair("yyyy", bYyyy), new NameValuePair("country", loc), new NameValuePair("postalcode", postalCode), new NameValuePair("yahooid", Email), new NameValuePair("password", Passwrd), new NameValuePair("passwordconfirm", passwrdAgain), new NameValuePair("altemail", this.alterEmail), new NameValuePair("secquestion", selection), new NameValuePair("secquestionanswer", this.IdentifyAnswer), new NameValuePair("cword", newaccountcaptcha), new NameValuePair("cdata", this._continue), new NameValuePair("tos_agreed", this.doAgree), new NameValuePair("IAgreeBtn", submitbutton) }; PostMethod postMethod = new PostMethod(URL); postMethod.setRequestBody(formData); int statusCode = 0; try { statusCode = client.executeMethod(hc, postMethod); System.out.println("Register Send: " + postMethod.getStatusLine().toString()); postMethod.releaseConnection(); }catch (HttpException e) { postMethod.releaseConnection(); System.out.println("HTTP EXception : " + e.getMessage()); }catch (IOException ie) { postMethod.releaseConnection(); System.out.println("Error Exe Method - Post. Status Code = " + statusCode); ie.printStackTrace(); } // To find whether logon is suceeded is, retreive the cookie Cookie[] logoncookies = cookiespec.match( ymailSinupUrl, hc.getPort(), "/", false, client.getState().getCookies()); System.out.println("Logon cookies:"); if (logoncookies.length == 0) { System.out.println("None"); } else { for (int i = 0; i < logoncookies.length; i++) { System.out.println("- " + logoncookies[i].toString()); } } // Save the url in lastUrl to keep track of try { lastUrl = postMethod.getURI().toString(); } catch (HttpException he) { he.printStackTrace(); } statusCode = postMethod.getStatusCode(); if ((statusCode == HttpStatus.SC_MOVED_TEMPORARILY) || (statusCode == HttpStatus.SC_MOVED_PERMANENTLY) || (statusCode == HttpStatus.SC_SEE_OTHER) || (statusCode == HttpStatus.SC_TEMPORARY_REDIRECT)) { Header header = postMethod.getResponseHeader("Location"); if (header != null) { String newUri = header.getValue(); System.out.println("Header Location = " + newUri); if ((newUri == null) || (newUri.equals(""))) { newUri = "/"; } try { // REQUIRES RE-DIRECT System.out.println("RE DIRECTING TARGET ....."); GetMethod redirect = new GetMethod(h.getValue()); redirect.setRequestHeader("Cookie",logoncookies.toString()); client.executeMethod(redirect); InputStream inputStream = null; BufferedReader input = null; try { inputStream = redirect.getResponseBodyAsStream(); input = new BufferedReader(new InputStreamReader(inputStream)); String str; StringBuffer response = new StringBuffer(); while((str = input.readLine()) != null) { response.append((new StringBuilder()).append(str).append("\n").toString()); res = (new StringBuilder()).append(res).append(str).toString(); } res = response.toString(); input.close(); } catch (IOException ie) { redirect.releaseConnection(); ie.printStackTrace(); } System.out.println("Redirect: " + redirect.getStatusLine().toString()); System.out.println("Redirect: " + redirect.getRequestHeader("path")); // release any connection resources used by the method redirect.releaseConnection(); } catch (Exception e) { System.out.println("Exp in Redirecting:-" + e.getMessage()); e.printStackTrace(); } } else { System.out.println("Invalid Redirect..........."); System.exit(1); } } System.out.println((new StringBuilder()).append("Status Code = ").append(statusCode).toString()); System.out.println("REPLY FROM POS = " + res); return res; } [/code] tHE dEBUG of whole program is as follows: [code] init: deps-jar: Compiling 1 source file to E:\Trupti\Projects\Sol Edad\Yname Maker\build\classes compile: 2007/11/22 15:11:07:090 IST [DEBUG] HttpClient - Java version: 1.6.0_02 2007/11/22 15:11:07:090 IST [DEBUG] HttpClient - Java vendor: Sun Microsystems Inc. 2007/11/22 15:11:07:090 IST [DEBUG] HttpClient - Java class path: E:\Trupti\JakartaApache\commons-codec-1.3.jar;E:\Trupti\JakartaApache\commons-httpclient-3.0.1.jar;E:\Trupti\JakartaApache\commons-lang-2.3.jar;E:\Trupti\JakartaApache\commons-logging-1.1.jar;E:\Trupti\Projects\Sol Edad\Yname Maker\build\classes 2007/11/22 15:11:07:090 IST [DEBUG] HttpClient - Operating system name: Windows XP 2007/11/22 15:11:07:090 IST [DEBUG] HttpClient - Operating system architecture: x86 2007/11/22 15:11:07:090 IST [DEBUG] HttpClient - Operating system version: 5.1 2007/11/22 15:11:07:215 IST [DEBUG] HttpClient - SUN 1.6: SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; JavaLoginConfig Configuration) 2007/11/22 15:11:07:231 IST [DEBUG] HttpClient - SunRsaSign 1.5: Sun RSA signature provider 2007/11/22 15:11:07:231 IST [DEBUG] HttpClient - SunJSSE 1.6: Sun JSSE provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1) 2007/11/22 15:11:07:231 IST [DEBUG] HttpClient - SunJCE 1.6: SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC) 2007/11/22 15:11:07:231 IST [DEBUG] HttpClient - SunJGSS 1.0: Sun (Kerberos v5, SPNEGO) 2007/11/22 15:11:07:231 IST [DEBUG] HttpClient - SunSASL 1.5: Sun SASL provider(implements client mechanisms for: DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5; server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5) 2007/11/22 15:11:07:231 IST [DEBUG] HttpClient - XMLDSig 1.0: XMLDSig (DOM XMLSignatureFactory; DOM KeyInfoFactory) 2007/11/22 15:11:07:231 IST [DEBUG] HttpClient - SunPCSC 1.6: Sun PC/SC provider 2007/11/22 15:11:07:231 IST [DEBUG] HttpClient - SunMSCAPI 1.6: Sun's Microsoft Crypto API provider 2007/11/22 15:11:07:231 IST [DEBUG] DefaultHttpParams - Set parameter http.useragent = Jakarta Commons-HttpClient/3.0.1 2007/11/22 15:11:07:231 IST [DEBUG] DefaultHttpParams - Set parameter http.protocol.version = HTTP/1.1 2007/11/22 15:11:07:231 IST [DEBUG] DefaultHttpParams - Set parameter http.connection-manager.class = class org.apache.commons.httpclient.SimpleHttpConnectionManager 2007/11/22 15:11:07:231 IST [DEBUG] DefaultHttpParams - Set parameter http.protocol.cookie-policy = rfc2109 2007/11/22 15:11:07:231 IST [DEBUG] DefaultHttpParams - Set parameter http.protocol.element-charset = US-ASCII 2007/11/22 15:11:07:231 IST [DEBUG] DefaultHttpParams - Set parameter http.protocol.content-charset = ISO-8859-1 2007/11/22 15:11:07:231 IST [DEBUG] DefaultHttpParams - Set parameter http.method.retry-handler = [EMAIL PROTECTED] 2007/11/22 15:11:07:231 IST [DEBUG] DefaultHttpParams - Set parameter http.dateparser.patterns = [EEE, dd MMM yyyy HH:mm:ss zzz, EEEE, dd-MMM-yy HH:mm:ss zzz, EEE MMM d HH:mm:ss yyyy, EEE, dd-MMM-yyyy HH:mm:ss z, EEE, dd-MMM-yyyy HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z, EEE dd-MMM-yyyy HH:mm:ss z, EEE dd MMM yyyy HH:mm:ss z, EEE dd-MMM-yyyy HH-mm-ss z, EEE dd-MMM-yy HH:mm:ss z, EEE dd MMM yy HH:mm:ss z, EEE,dd-MMM-yy HH:mm:ss z, EEE,dd-MMM-yyyy HH:mm:ss z, EEE, dd-MM-yyyy HH:mm:ss z] 2007/11/22 15:11:07:246 IST [DEBUG] DefaultHttpParams - Set parameter http.protocol.version = HTTP/1.0 2007/11/22 15:11:07:246 IST [DEBUG] DefaultHttpParams - Set parameter http.protocol.version = HTTP/1.0 Landing on Signup Page 2007/11/22 15:11:07:246 IST [DEBUG] DefaultHttpParams - Set parameter http.protocol.cookie-policy = null 2007/11/22 15:11:07:293 IST [DEBUG] DefaultHttpParams - Set parameter http.method.rety-handler = [EMAIL PROTECTED] 2007/11/22 15:11:07:309 IST [DEBUG] HttpConnection - Open connection to edit.yahoo.com:443 2007/11/22 15:11:07:981 IST [DEBUG] header - >> "GET /registration?.intl=us&new=1&.done=http HTTP/1.0[\r][\n]" 2007/11/22 15:11:07:981 IST [DEBUG] HttpMethodBase - Adding Host request header 2007/11/22 15:11:08:012 IST [DEBUG] header - >> "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20061201 Firefox/2.0.0.3 (Ubuntu-feisty)[\r][\n]" 2007/11/22 15:11:08:012 IST [DEBUG] header - >> "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5[\r][\n]" 2007/11/22 15:11:08:012 IST [DEBUG] header - >> "Accept-Language: en-US[\r][\n]" 2007/11/22 15:11:08:012 IST [DEBUG] header - >> "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7[\r][\n]" 2007/11/22 15:11:08:012 IST [DEBUG] header - >> "Keep-Alive: 300[\r][\n]" 2007/11/22 15:11:08:012 IST [DEBUG] header - >> "Connection: keep-alive[\r][\n]" 2007/11/22 15:11:08:012 IST [DEBUG] header - >> "Host: edit.yahoo.com[\r][\n]" 2007/11/22 15:11:08:012 IST [DEBUG] header - >> "[\r][\n]" 2007/11/22 15:11:09:652 IST [DEBUG] header - << "HTTP/1.1 200 OK[\r][\n]" 2007/11/22 15:11:09:652 IST [DEBUG] header - << "Date: Thu, 22 Nov 2007 09:41:08 GMT[\r][\n]" 2007/11/22 15:11:09:652 IST [DEBUG] header - << "Set-Cookie: B=ef69pm53kajlk&b=3&s=q3; expires=Tue, 02-Jun-2037 20:00:00 GMT; path=/; domain=.yahoo.com[\r][\n]" 2007/11/22 15:11:09:652 IST [DEBUG] header - << "P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"[\r][\n]" 2007/11/22 15:11:09:652 IST [DEBUG] header - << "Cache-control: no-cache[\r][\n]" 2007/11/22 15:11:09:652 IST [DEBUG] header - << "Pragma: no-cache[\r][\n]" 2007/11/22 15:11:09:652 IST [DEBUG] header - << "Expires: 0[\r][\n]" 2007/11/22 15:11:09:652 IST [DEBUG] header - << "Connection: close[\r][\n]" 2007/11/22 15:11:09:652 IST [DEBUG] header - << "Content-Type: text/html[\r][\n]" 2007/11/22 15:11:09:699 IST [DEBUG] HttpMethodBase - Cookie accepted: "$Version=0; B=ef69pm53kajlk&b=3&s=q3; $Path=/; $Domain=.yahoo.com" Status Code = 200 Got RESPONSE :- ***************************** HTML CODE **************************************** Initial set of cookies: Ini Cookies: None Cookie = B = ef69pm53kajlk&b=3&s=q3 Form Action = /registration;_ylt=A9FJq3.0TkVHN80ADgCZ2PAI Captcha URL - https://ab.login.yahoo.com/img/4.tPSeVZFemXYoQV0NICmWnGQ501fk1P1.dvnHUeJXY.iqAJA.in8Ne.4Q6e64fly4gkf3kRkQ--.jpg Continue = 4.tPSeVZFemXYoQV0NICmWnGQ501fk1P1.dvnHUeJXY.iqAJA.in8Ne.4Q6e64fly4gkf3kRkQ-- DSH - U = c43neat3kajlk T1 = 0kGqAw2P05N6ep_jQ3V10QQtjOlDOl1TAvxdpkLTjgc1qW0i_V89yZbsoWFsk9Wl4KUh9vEmpnQ4_qp68PmUEimVv9mFLdRDUju7iDo8fQQ1hhbeL48NxPQD5i_aaZ3Pi6TJXAhoEuTL3QUqRn9CsKi6s.hqPg32AK_DBTCEwY0-~B Dracs = POSTING FORM .... 2007/11/22 15:11:33:401 IST [DEBUG] HttpConnection - Open connection to edit.yahoo.com:443 2007/11/22 15:11:33:760 IST [DEBUG] header - >> "POST /registration?.intl=us&new=1&.done=http&_ylt=A9FJpMBjCkRHERcBDgCZ2PAI HTTP/1.0[\r][\n]" 2007/11/22 15:11:33:776 IST [DEBUG] HttpMethodBase - Adding Host request header 2007/11/22 15:11:33:792 IST [DEBUG] HttpMethodBase - Default charset used: ISO-8859-1 2007/11/22 15:11:33:995 IST [DEBUG] HttpMethodBase - Default charset used: ISO-8859-1 2007/11/22 15:11:34:182 IST [DEBUG] header - >> "User-Agent: Jakarta Commons-HttpClient/3.0.1[\r][\n]" 2007/11/22 15:11:34:213 IST [DEBUG] header - >> "Host: edit.yahoo.com[\r][\n]" 2007/11/22 15:11:34:229 IST [DEBUG] header - >> "Cookie: $Version=0; B=ef69pm53kajlk&b=3&s=q3; $Path=/; $Domain=.yahoo.com[\r][\n]" 2007/11/22 15:11:34:245 IST [DEBUG] header - >> "Content-Length: 676[\r][\n]" 2007/11/22 15:11:34:276 IST [DEBUG] header - >> "Content-Type: application/x-www-form-urlencoded[\r][\n]" 2007/11/22 15:11:34:292 IST [DEBUG] header - >> "[\r][\n]" 2007/11/22 15:11:35:370 IST [DEBUG] EntityEnclosingMethod - Request body sent 2007/11/22 15:11:35:682 IST [DEBUG] header - << "HTTP/1.1 301 Moved Permanently[\r][\n]" 2007/11/22 15:11:35:729 IST [DEBUG] header - << "Date: Thu, 22 Nov 2007 09:41:35 GMT[\r][\n]" 2007/11/22 15:11:35:745 IST [DEBUG] header - << "Location: http://edit.yahoo.com/registration?.intl=us&new=1&.done=http[\r][\n]" 2007/11/22 15:11:35:760 IST [DEBUG] header - << "Connection: close[\r][\n]" 2007/11/22 15:11:35:776 IST [DEBUG] header - << "Content-Type: text/html[\r][\n]" 2007/11/22 15:11:35:791 IST [DEBUG] HttpMethodDirector - Redirect required 2007/11/22 15:11:35:791 IST [INFO] HttpMethodDirector - Redirect requested but followRedirects is disabled Register Send: HTTP/1.1 301 Moved Permanently 2007/11/22 15:11:39:604 IST [DEBUG] HttpMethodBase - Should close connection in response to directive: close 2007/11/22 15:11:39:619 IST [DEBUG] HttpConnection - Releasing connection back to connection manager. Logon cookies: None Header = http://edit.yahoo.com/registration?.intl=us&new=1&.done=http RE DIRECTING TARGET ..... 2007/11/22 15:12:02:384 IST [DEBUG] HttpConnection - Open connection to edit.yahoo.com:80 2007/11/22 15:12:02:727 IST [DEBUG] header - >> "GET /registration?.intl=us&new=1&.done=http HTTP/1.0[\r][\n]" 2007/11/22 15:12:02:743 IST [DEBUG] HttpMethodBase - Adding Host request header 2007/11/22 15:12:02:759 IST [DEBUG] header - >> "Cookie: [Lorg.apache.commons.httpclient.Cookie;@e4776b[\r][\n]" 2007/11/22 15:12:02:790 IST [DEBUG] header - >> "User-Agent: Jakarta Commons-HttpClient/3.0.1[\r][\n]" 2007/11/22 15:12:02:821 IST [DEBUG] header - >> "Host: edit.yahoo.com[\r][\n]" 2007/11/22 15:12:02:837 IST [DEBUG] header - >> "Cookie: $Version=0; B=ef69pm53kajlk&b=3&s=q3; $Path=/; $Domain=.yahoo.com[\r][\n]" 2007/11/22 15:12:02:852 IST [DEBUG] header - >> "[\r][\n]" 2007/11/22 15:12:06:196 IST [DEBUG] header - << "HTTP/1.1 302 Found[\r][\n]" 2007/11/22 15:12:06:243 IST [DEBUG] header - << "Date: Thu, 22 Nov 2007 09:42:02 GMT[\r][\n]" 2007/11/22 15:12:06:290 IST [DEBUG] header - << "P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"[\r][\n]" 2007/11/22 15:12:06:305 IST [DEBUG] header - << "Location: https://edit.yahoo.com/registration?_intl=us&new=1&_done=http[\r][\n]" 2007/11/22 15:12:06:321 IST [DEBUG] header - << "Connection: close[\r][\n]" 2007/11/22 15:12:06:337 IST [DEBUG] header - << "Content-Type: text/html[\r][\n]" 2007/11/22 15:12:06:352 IST [DEBUG] HttpMethodDirector - Redirect required 2007/11/22 15:12:06:368 IST [DEBUG] HttpMethodDirector - Redirect requested to location 'https://edit.yahoo.com/registration?_intl=us&new=1&_done=http' 2007/11/22 15:12:06:415 IST [DEBUG] HttpMethodDirector - Redirecting from 'http://edit.yahoo.com:80/registration' to 'https://edit.yahoo.com/registration 2007/11/22 15:12:06:430 IST [DEBUG] HttpMethodDirector - Execute redirect 1 of 100 2007/11/22 15:12:06:446 IST [DEBUG] HttpMethodBase - Should close connection in response to directive: close 2007/11/22 15:12:06:462 IST [DEBUG] HttpConnection - Connection is locked. Call to releaseConnection() ignored. 2007/11/22 15:12:06:462 IST [DEBUG] HttpConnection - Releasing connection back to connection manager. 2007/11/22 15:12:06:477 IST [DEBUG] HttpConnection - Open connection to edit.yahoo.com:443 2007/11/22 15:12:06:821 IST [DEBUG] header - >> "GET /registration?_intl=us&new=1&_done=http HTTP/1.1[\r][\n]" 2007/11/22 15:12:06:837 IST [DEBUG] HttpMethodBase - Adding Host request header 2007/11/22 15:12:06:868 IST [DEBUG] header - >> "Cookie: [Lorg.apache.commons.httpclient.Cookie;@e4776b[\r][\n]" 2007/11/22 15:12:06:899 IST [DEBUG] header - >> "User-Agent: Jakarta Commons-HttpClient/3.0.1[\r][\n]" 2007/11/22 15:12:06:915 IST [DEBUG] header - >> "Host: edit.yahoo.com[\r][\n]" 2007/11/22 15:12:06:930 IST [DEBUG] header - >> "Cookie: $Version=0; B=ef69pm53kajlk&b=3&s=q3; $Path=/; $Domain=.yahoo.com[\r][\n]" 2007/11/22 15:12:06:962 IST [DEBUG] header - >> "[\r][\n]" 2007/11/22 15:12:09:493 IST [DEBUG] header - << "HTTP/1.1 200 OK[\r][\n]" 2007/11/22 15:12:09:555 IST [DEBUG] header - << "Date: Thu, 22 Nov 2007 09:42:07 GMT[\r][\n]" 2007/11/22 15:12:09:571 IST [DEBUG] header - << "P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"[\r][\n]" 2007/11/22 15:12:09:602 IST [DEBUG] header - << "Cache-control: no-cache[\r][\n]" 2007/11/22 15:12:09:618 IST [DEBUG] header - << "Pragma: no-cache[\r][\n]" 2007/11/22 15:12:09:633 IST [DEBUG] header - << "Expires: 0[\r][\n]" 2007/11/22 15:12:09:649 IST [DEBUG] header - << "Connection: close[\r][\n]" 2007/11/22 15:12:09:665 IST [DEBUG] header - << "Transfer-Encoding: chunked[\r][\n]" 2007/11/22 15:12:09:680 IST [DEBUG] header - << "Content-Type: text/html[\r][\n]" 2007/11/22 15:12:28:523 IST [DEBUG] HttpMethodBase - Should close connection in response to directive: close 2007/11/22 15:12:28:523 IST [DEBUG] HttpConnection - Releasing connection back to connection manager. [/code] The bold text says, that the header has some reference to go to other site, but the redirect.getResponseBodyAsStream(); returns the same page as Get. What is that I am lacking. Any help is highly appreciated. Please guide me, I am in need of help. Thanks Trupti -- View this message in context: http://www.nabble.com/Redirect-not-working-of-POST-tf4857582.html#a13900442 Sent from the HttpClient-User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]