470,644 Members | 1,202 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,644 developers. It's quick & easy.

Having problem in org.apache.commons.httpclient.methods.PostMethod?? ??

Hi all,
I am not able to login a site using the following code,
can anyone suggest me the right way?
There is no any https connection.

HttpClient client=new HttpClient();
client.getParams().setCookiePolicy(CookiePolicy.BR OWSER_COMPATIBILITY);

String userAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
String connection="Keep-Alive";

PostMethod postMethod = new PostMethod("url");
postMethod.addRequestHeader("User-Agent",userAgent );
postMethod.addRequestHeader("Connection", connection);
HttpConnectionManager connectionManager = client.getHttpConnectionManager();
connectionManager.getParams().setConnectionTimeout (8000);

NameValuePair[] nameValue =new NameValuePair[3];
nameValue[0]=new NameValuePair("username","xxxxx");
nameValue[1]=new NameValuePair("password","xxxxx");
nameValue[2]=new NameValuePair("submit1","OK");
int status=client.executeMethod(postMethod);
StringTokenizer st1 =
new StringTokenizer(postMethod.getResponseBodyAsString ());

Feb 7 '08 #1
0 3597

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Leo | last post: by
1 post views Thread by mirandacascade | last post: by
1 post views Thread by Carmen Sei | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.