Redirect not working of POST

2007-11-22 Thread terry_513


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(, 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 

Re: Redirect not working of POST

2007-11-22 Thread terry_513


Thanks Ronald, 


 In a browser, you'd probably see
 an additional message like you have to enter a value
 in this field.

   In browser, if I put the same form details as passed, if any thing is
wrong, I see a message. To capture the same I have written code for it. So,
does this imply, that if some data is wrong, it wont show me that page as we
see in browser, but return the saem page. The code written to trace the
message is
code
String postRes = POST(formAction, data);

// SUCCEDED
String tmpRegEx = Congratulations,;
Pattern pattern = Pattern.compile(tmpRegEx, 10);
Matcher matcher = pattern.matcher(postRes);
int success = 0;
if (matcher.find()) {
System.out.println(ACCOUNT CREATED SUCCESSFULLY);
success = 1;
} else {
success = 0;
}

// WRONG CAPTCHA
tmpRegEx = Please try this code instead;
pattern.compile(tmpRegEx, 10);
matcher = pattern.matcher(postRes);
if (matcher.find()) {
System.out.println(INCORRECT CAPTCHA);
return -1;
}

// ID alredy EXISTS
tmpRegEx = This ID is not available;
pattern.compile(tmpRegEx, 10);
matcher = pattern.matcher(postRes);
if (matcher.find()) {
System.out.println(INCORRECT ID);
return -1;
}

// Looks like there was some trouble creating your account. Please
take a moment to review your answers. - Some improper info
tmpRegEx = Looks like there was some trouble creating your account.
Please take a moment to review your answers;
pattern.compile(tmpRegEx, 10);
matcher = pattern.matcher(postRes);
if (matcher.find()) {
System.out.println(INCORRECT DATA PASSED);
return -1;
}
/code



Roland Weber wrote:
 
 Check the data you are posting. Check twice that you
 send all hidden parameters,

Here is where, I may be wrong. All form fields values are correct,  other
extracted values are also correct. But, I am not sure, which hidden fields
to pass. I may be wrong in setting the form fields. Their are 2 submit
button I Agree  I don't Agree. I have added I Agree. I have added the
action parameter found in form tag. And a check box, which I want to
click, so have put its value as 1. For Select fields, I have given text 
not value. Like for month April value is 4, I have given April in month
value instead of 4. These are the points for form fields where I may be
wrong. And reg other hidden fields, I can't make out which to add. I have
added u, t  cdata. The url I am looking at is:
https://edit.yahoo.com/registration?.intl=usnew=1.done=http  


It's best to grab the request sent by a browser and compare the data. 
I have downloaded wireshark, but can't find a way to find out the parameters
of post. Can you please give directions / guidelines to know the parameters
of the request sent.

It would be very kind of you, if you can guide me with the fields. Setting
select, check box, other mentioned above  hidden fields. Hope you cna help
and guide me.

Thanks a lot in advance



If you get a redirect to the same form you came from,
that typically means that the server didn't like the
data you entered. 
Check the data you are posting. Check twice that you
send all hidden parameters, and a value for every
field where you have to enter data, and for every
checkbox you have to set.  There may even
be some JavaScript somewhere in the page that modifies
the parameters or target URL when the form is submitted
by a browser.

hope that helps,
  Roland

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
View this message in context: 
http://www.nabble.com/Redirect-not-working-of-POST-tf4857582.html#a13907286
Sent from the HttpClient-User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Why is POST (HttpClient) is acting like this?

2007-11-21 Thread terry_513


Thanks Oleg. After some Rnd, now the same page is coming on post response. 
Their are programs that work through such sites via desktop application.
What am I lacking, that I get wrong results? Their must be something to work
with these sites also. Any idea or suggestion would be of great help. If you
want, I can pass you the code. 

Please help me. I see in this site, you and other experts have helped so
many people. Please.

Thanks




olegk wrote:
 
 
 On Tue, 2007-11-20 at 23:15 -0800, terry_513 wrote:
 
 Hello, 
 
   In my desktop application, using HttpClient 3.1, I am navigating a web
 site. I am trying to retreive the site
 https://edit.yahoo.com/registration?.intl=usnew=1.done=http, I pass the
 respective parameters and perform a POST. The post requires redirect. So,
 I
 get the Location from the header which points to http://yahoo.com; and
 get the new location url via GET method.
 
My problem is: the submission if form should be going somehwere else,
 but
 it is going to the home page. Why so? Where I may be going wrong? The
 code
 doesn't throw any exception or error. But the page that I receive is not
 expected. Any idea, guidance will be of great help.
 
 Thanks
 
 
 
 
 This has nothing to do with HttpClient. Yahoo and many other high
 profile sites are known to employ various techniques to detect and
 prevent automated screen-scraping.
 
 Oleg
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Why-is-POST-%28HttpClient%29-is-acting-like-this--tf4848502.html#a13875050
Sent from the HttpClient-User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Why is POST (HttpClient) is acting like this?

2007-11-21 Thread terry_513
 dynamically  passed. I
had also added these parameters, but removed it as they remain same in all
pages.

//new NameValuePair(dracs, dracs), new NameValuePair(done, _done), new
NameValuePair(last, ), new NameValuePair(partner, _partner), new
NameValuePair(src, new String()), new NameValuePair(intl, new
String(us)), new NameValuePair(jsenabled, new String(0)),
//, new NameValuePair(action, formAction)

// URL - https://edit.yahoo.com/registration?.intl=usnew=1.done=http
// formAction - /registration;_ylt=A9FJpMTzzUJHpgIADgCZ2PAI
POST /registration?.intl=usnew=1.done=http_ylt=A9FJpMBjCkRHERcBDgCZ2PAI
HTTP/1.0[\r][\n]


This is the source of the post method  its required resources. Can anyone
know, where  what is the error? Why does the post refer to the same page
instead of next page. I am in very bad shape to solve this problem. Please
if, any one can help me out. Any help is highly appreciated.


Thanks 



sebb-2-2 wrote:
 
 You could use a protocol analyser such as WireShark
 (www.wireshark.org) to compare the requests sent by a browser and
 those sent by your application.
 
 Some browsers also offer add-ons to show the HTTP traffic. Check what
 the browser is sending, and ensure that your application follows that
 as closely as possible.
 
 On 21/11/2007, terry_513 [EMAIL PROTECTED] wrote:


 Thanks Oleg. After some Rnd, now the same page is coming on post
 response.
 Their are programs that work through such sites via desktop application.
 What am I lacking, that I get wrong results? Their must be something to
 work
 with these sites also. Any idea or suggestion would be of great help. If
 you
 want, I can pass you the code.

 Please help me. I see in this site, you and other experts have helped so
 many people. Please.

 Thanks




 olegk wrote:
 
 
  On Tue, 2007-11-20 at 23:15 -0800, terry_513 wrote:
 
  Hello,
 
In my desktop application, using HttpClient 3.1, I am navigating a
 web
  site. I am trying to retreive the site
  https://edit.yahoo.com/registration?.intl=usnew=1.done=http, I pass
 the
  respective parameters and perform a POST. The post requires redirect.
 So,
  I
  get the Location from the header which points to http://yahoo.com;
 and
  get the new location url via GET method.
 
 My problem is: the submission if form should be going somehwere
 else,
  but
  it is going to the home page. Why so? Where I may be going wrong? The
  code
  doesn't throw any exception or error. But the page that I receive is
 not
  expected. Any idea, guidance will be of great help.
 
  Thanks
 
 
 
 
  This has nothing to do with HttpClient. Yahoo and many other high
  profile sites are known to employ various techniques to detect and
  prevent automated screen-scraping.
 
  Oleg
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 
 

 --
 View this message in context:
 http://www.nabble.com/Why-is-POST-%28HttpClient%29-is-acting-like-this--tf4848502.html#a13875050
 Sent from the HttpClient-User mailing list archive at Nabble.com.


 -
 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]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Why-is-POST-%28HttpClient%29-is-acting-like-this--tf4848502.html#a13878617
Sent from the HttpClient-User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Why is POST (HttpClient) is acting like this?

2007-11-21 Thread terry_513


Sebb, 

   How do I use WireShark to get the info? I have never used before. Can you
guide me, please.

Thanks
-- 
View this message in context: 
http://www.nabble.com/Why-is-POST-%28HttpClient%29-is-acting-like-this--tf4848502.html#a13881292
Sent from the HttpClient-User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Why is POST (HttpClient) is acting like this?

2007-11-21 Thread terry_513


The web site, i am working with is 
https://edit.yahoo.com/registration?.intl=usnew=1.done=http
-- 
View this message in context: 
http://www.nabble.com/Why-is-POST-%28HttpClient%29-is-acting-like-this--tf4848502.html#a13881716
Sent from the HttpClient-User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Help needed to figure out Headers Post paramete

2007-11-20 Thread terry_513
] HttpConnection - Open connection to
edit.yahoo.com:443
2007/11/21 10:45:06:218 IST [DEBUG] header -  POST
/registration?.intl=usnew=1.done=http/registration;_ylt=A9G_XG22vkNHmYcADgCZ2PAI
HTTP/1.1[\r][\n]
2007/11/21 10:45:06:234 IST [DEBUG] HttpMethodBase - Adding Host request
header
2007/11/21 10:45:06:265 IST [DEBUG] HttpMethodBase - Default charset used:
ISO-8859-1
2007/11/21 10:45:06:484 IST [DEBUG] HttpMethodBase - Default charset used:
ISO-8859-1
2007/11/21 10:45:06:687 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/21 10:45:06:718 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/21 10:45:06:734 IST [DEBUG] header -  Accept-Language:
en-US[\r][\n]
2007/11/21 10:45:06:765 IST [DEBUG] header -  Accept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.7[\r][\n]
2007/11/21 10:45:06:781 IST [DEBUG] header -  Keep-Alive: 300[\r][\n]
2007/11/21 10:45:06:796 IST [DEBUG] header -  Connection:
keep-alive[\r][\n]
2007/11/21 10:45:06:828 IST [DEBUG] header -  Referer:
https://edit.yahoo.com/registration?.intl=usnew=1.done=http[\r][\n];
2007/11/21 10:45:06:843 IST [DEBUG] header -  Host:
edit.yahoo.com[\r][\n]
2007/11/21 10:45:06:875 IST [DEBUG] header -  Cookie: $Version=0;
B=1vb71it3k7flmb=3s=el; $Path=/; $Domain=.yahoo.com[\r][\n]
2007/11/21 10:45:06:890 IST [DEBUG] header -  Content-Length:
697[\r][\n]
2007/11/21 10:45:06:906 IST [DEBUG] header -  Content-Type:
application/x-www-form-urlencoded[\r][\n]
2007/11/21 10:45:06:921 IST [DEBUG] header -  [\r][\n]
2007/11/21 10:45:08:062 IST [DEBUG] EntityEnclosingMethod - Request body
sent
2007/11/21 10:45:08:421 IST [DEBUG] header -  HTTP/1.1 302 Found[\r][\n]
2007/11/21 10:45:08:468 IST [DEBUG] header -  Date: Wed, 21 Nov 2007
05:15:07 GMT[\r][\n]
2007/11/21 10:45:08:500 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/21 10:45:08:515 IST [DEBUG] header -  Location:
http://www.yahoo.com/[\r][\n];
2007/11/21 10:45:08:531 IST [DEBUG] header -  Connection: close[\r][\n]
2007/11/21 10:45:08:546 IST [DEBUG] header -  Transfer-Encoding:
chunked[\r][\n]
2007/11/21 10:45:08:562 IST [DEBUG] header -  Content-Type:
text/html[\r][\n]
2007/11/21 10:45:08:578 IST [DEBUG] HttpMethodDirector - Redirect required
2007/11/21 10:45:08:593 IST [INFO] HttpMethodDirector - Redirect requested
but followRedirects is disabled
Register Send: HTTP/1.1 302 Found
POST Method failed: HTTP/1.1 302 Found
Status Code = 302
Header Location = http://www.yahoo.com/
2007/11/21 10:45:32:046 IST [DEBUG] HttpMethodBase - Should close connection
in response to directive: close
2007/11/21 10:45:32:062 IST [DEBUG] HttpConnection - Releasing connection
back to connection manager.
REPLY FROM POS = 


In post, you can see, a Redirect is required. Status code is 302 Found 
the response that I receive from Post is   the Locations is the home
page. What do I do to solve this, why the post response is . Am I missing
any thing more here. Please help me out.

Thanks



Puneet Lakhina wrote:
 
 On Nov 21, 2007 9:59 AM, Puneet Lakhina [EMAIL PROTECTED] wrote:
 


 On Nov 19, 2007 4:40 PM, terry_513 [EMAIL PROTECTED] wrote:

 
 
  Hello,
 
 I am new on this site, in need of help. Hope you experts will help a
  beginner.
 
 I am developing an application where, I have to login to web site,
  etc
  programmatically. I can access the web page, retreive the page. So, GET
  part
  is working fine. I have problem with Post. I am using JDK
  1.6 with apache's HttpClient 3.1 for communicating through the web
 site.
  After setting parameters in NameValuePair[], when i run
  execuseMethod(postMethod), it throws the following exception :
 
  i]Exception in thread AWT-EventQueue-0
  java.lang.IllegalArgumentException:
  host parameter is null


 This is Java Swing API error, please check that part of your code. In
 case
 that doesnt solve the problem, please full exception trace.

 Saw your other post now, the above is wrong, its something to do with
 httpclient only. Sorry.
 Could you please try printing out the url parameter that you are taking as
 argument in your method, to check if thats null or not.
 


I think, I may be going wrong in providing proper headers,
 parameters,
 
  etc. Can anyone help me know:
 
  1. How to implement log in my application. I think that will help me
  know
  the headers  all erros  exceptions.I tried a lot, but couldn't
  implement
  the Logging, if any one can guide me for that , would be great.


 http://jakarta.apache.org/httpcomponents/httpclient-3.x/logging.html

 
  2. How can I know what parameters, I need to pass in the POST method.
  Along
  with form attributes, their may be any hidden values

How to rectify 302 Found message from POST method ?

2007-11-20 Thread terry_513

Hello Friends, 

I am developing a desktop application where I got to navigate to a web
site. Previously I was getting host parameter is null exception while Post
method. I solved the error by setting the host of the client -
client.getHostConfiguration().setHost(Url, 443, https);  passed
HostConfiguration object along with executing post method. 

   Now, I am facing another problem of 302 Found response from post. Post
runs without any error. This is my Post code: 
[code] 
public String POST(String url, NameValuePair[] data) { 
String res = ; 
String URL = ymailSinupUrl + url; 
PostMethod method = new PostMethod(URL); 
// SET PROPERTIES 
method.getParams().setParameter(http.method.retry-handler, new
DefaultHttpMethodRetryHandler(3, false)); 
method.setRequestHeader(User-agent, USER_AGENT); 
method.setRequestHeader(Accept, ACCEPT); 
method.setRequestHeader(Accept-Language, ACCEPT_LANG); 
//method.setRequestHeader(Accept-Encoding, ACCEPT_ENC); 
method.setRequestHeader(Accept-Charset, ACCEPT_CHAR); 
method.setRequestHeader(Keep-Alive, KEEP_ALIVE); 
method.setRequestHeader(Connection, CONNECTION); 


if (! .equals(lastUrl)) 
method.setRequestHeader(Referer, lastUrl); 

if (connectMgr.getConnection(hc).isOpen() == true) 
System.out.println(Connection is OPEN); 
else { 
System.out.println(Connection is *** NOT OPEN
*** ); 
} 
method.setRequestBody(data); 

int statusCode = 0; 
try { 
statusCode = client.executeMethod(hc, method); 
System.out.println(Register Send:  +
method.getStatusLine().toString()); 
}catch (HttpException e) { 
method.releaseConnection(); 
System.out.println(HTTP EXception :  + e.getMessage()); 
}catch (IOException ie) { 
method.releaseConnection(); 
System.out.println(Error Exe Method - Post. Status Code =  +
statusCode); 
ie.printStackTrace(); 
} 

if (statusCode != 200) { 
System.err.println((new StringBuilder()).append(POST Method
failed: ).append(method.getStatusLine()).toString()); 
} else { 
InputStream inputStream = null; 
BufferedReader input = null; 
try { 
inputStream = method.getResponseBodyAsStream(); 
input = new BufferedReader(new
InputStreamReader(inputStream)); 
String str; 
while((str = input.readLine()) != null) { 
res = (new
StringBuilder()).append(res).append(str).toString(); 
} 
input.close(); 
} catch (IOException ie) { 
method.releaseConnection(); 
ie.printStackTrace(); 
} 
} 

System.out.println((new StringBuilder()).append(Status Code =
).append(statusCode).toString()); 
Header h; 
if (statusCode == 302) { 
h = method.getResponseHeader(Location); 
System.out.println(Header =  + h.getValue()); 
} 

try { 
lastUrl = method.getURI().toString(); 
} catch (HttpException he) { 
he.printStackTrace(); 
}finally { 
method.releaseConnection(); 
} 

return res; 
} 
[/code] 

And this is the whole log, that I get from start 
[code]
2007/11/21 10:44:26:234 IST [DEBUG] HttpClient - Java version: 1.6.0_02 
2007/11/21 10:44:26:250 IST [DEBUG] HttpClient - Java vendor: Sun
Microsystems Inc. 
2007/11/21 10:44:26:250 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/21 10:44:26:250 IST [DEBUG] HttpClient - Operating system name:
Windows XP 
2007/11/21 10:44:26:250 IST [DEBUG] HttpClient - Operating system
architecture: x86 
2007/11/21 10:44:26:250 IST [DEBUG] HttpClient - Operating system version:
5.1 
2007/11/21 10:44:26:640 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/21 10:44:26:640 IST [DEBUG] HttpClient - SunRsaSign 1.5: Sun RSA
signature provider 
2007/11/21 10:44:26:640 IST [DEBUG] HttpClient - SunJSSE 1.6: Sun JSSE
provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1) 
2007/11/21 10:44:26:640 IST [DEBUG] HttpClient - SunJCE 1.6: SunJCE Provider
(implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE,
Diffie-Hellman, HMAC) 
2007/11/21 

Why is POST (HttpClient) is acting like this?

2007-11-20 Thread terry_513


Hello, 

  In my desktop application, using HttpClient 3.1, I am navigating a web
site. I am trying to retreive the site
https://edit.yahoo.com/registration?.intl=usnew=1.done=http, I pass the
respective parameters and perform a POST. The post requires redirect. So, I
get the Location from the header which points to http://yahoo.com; and
get the new location url via GET method.

   My problem is: the submission if form should be going somehwere else, but
it is going to the home page. Why so? Where I may be going wrong? The code
doesn't throw any exception or error. But the page that I receive is not
expected. Any idea, guidance will be of great help.

Thanks


-- 
View this message in context: 
http://www.nabble.com/Why-is-POST-%28HttpClient%29-is-acting-like-this--tf4848502.html#a13872309
Sent from the HttpClient-User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Error Post a form

2007-11-19 Thread terry_513


Hello, 


I am developing an application where, I have to login to web site, etc.
I can access the web page, retreive the page. So, GET part is working fine.
I have problem with Post. I am using JDK 1.6 with apache's HttpClient 3.1
for communicating through the web site. After setting parameters in
NameValuePair[], when i run execuseMethod(postMethod), it throws the
following exception :

[i]Exception in thread AWT-EventQueue-0
java.lang.IllegalArgumentException: host parameter is null
at
org.apache.commons.httpclient.HttpConnection.setHost(HttpConnection.java:248)
at
org.apache.commons.httpclient.SimpleHttpConnectionManager.getConnectionWithTimeout
(SimpleHttpConnectionManager.java:163)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod
(HttpMethodDirector.java:152)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
at ynamemaker.YnameClient.POST(YnameClient.java:395)
at ynamemaker.YnameClient.createAccount(YnameClient.java:325)
at
ynamemaker.YAccCreatorForm.start_btnMouseClicked(YAccCreatorForm.java:97)
at ynamemaker.YAccCreatorForm.access$000(YAccCreatorForm.java:14)
at
ynamemaker.YAccCreatorForm$1.mouseClicked(YAccCreatorForm.java:42)
at
java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3995)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy

(EventDispatchThread.java:173)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at
java.awt.EventDispatchThread.run(EventDispatchThread.java:121)[/i]


 My post code is as follows:
public String POST(String url, NameValuePair[] data) {
String res = ;
PostMethod method = new PostMethod(url);
// SET PROPERTIES 
method.getParams().setParameter(http.method.retry-handler, new
DefaultHttpMethodRetryHandler(3, false));
method.setRequestHeader(User-agent, USER_AGENT);
method.setRequestHeader(Accept, ACCEPT);
method.setRequestHeader(Accept-Language, ACCEPT_LANG);
method.setRequestHeader(Accept-Charset, USER_AGENT);
method.setRequestHeader(Keep-Alive, KEEP_ALIVE);
method.setRequestHeader(Connection, CONNECTION);

method.setRequestBody(data);
int statusCode = 0;
try {
statusCode = client.executeMethod(method);  // EXCEPTION IS
THROWN
}catch (IOException ie) {
method.releaseConnection();
System.out.println(Error Exe Method - Post. Status Code =  +
statusCode);
ie.printStackTrace();
}

I went across the For Absolute Beginners :-  
http://jakarta.apache.org/httpcomponents/httpclient-3.x/logging.html site.
Grasped  corrected how much I understood. After this, I am not able to
figure out the problem.  
 Can any one PLEASE help me with this error. Any help is highly
appreciated. How can I know if the headers are wrong, or any extra
parameters need to be added, etc ? Can that be the reason for failure?


Thanks

Terry
-- 
View this message in context: 
http://www.nabble.com/Error-Post-a-form-tf4835421.html#a13833727
Sent from the HttpClient-User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]