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");
postMethod.setRequestBody(nameValue);
int status=client.executeMethod(postMethod);
StringTokenizer st1 =
new StringTokenizer(postMethod.getResponseBodyAsString ());
regards,
sundar