473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

58
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
Feb 7 '08 #1
0 3724

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

Similar topics

1
by: greg.knaddison | last post by:
Hi, I'm trying to use the httpclient within Jython (see http://jakarta.apache.org/commons/httpclient/ for more information on the httpclient). My Jython version is: Jython 2.1 on...
0
by: ShaSha | last post by:
Hi, I am trying to upload XML files via HTTP to an HTTP server from java client instead of browser. On the HTTP server side, there is a Perl script that will be receiving the incoming file and files...
4
by: Vincent | last post by:
Hello, Does anyone have a problem with Apache2 crashing after executing a PHP script with session_start()? I notice if session_start() is placed anywhere except at the start of the file, APache...
3
by: Leo | last post by:
Can anyone help or offer some explanation with this problem: I'm trying to do a POST from one of my PHP pages, to another page on my site using curl. To maintain the session I'm sending the...
4
by: nawrin22 | last post by:
hi.. I am a niwebie in 'AXIS' . but i had correctly installed it without any problem with the help of 'apache.axis.install.pdf' and also tested the examples under 'samples\userguide' directoy...
1
by: mirandacascade | last post by:
Operating system: Windows XP Home Version of Python: 2.4 While looking through the tutorial on ElementSOAP at the following link: http://effbot.org/zone/element-soap.htm I observed sample...
0
by: Roland | last post by:
Hello! Firstly, sorry for my poor English... :/ Next, I want to show you my library dll - HttpClient. This library can: - get page - submit form - download and upload file (you can monitor for...
5
by: e2point | last post by:
hi, if i extend an opensouce project that is given with Apache License, Version 2.0, will i be able to sell my extended work without making it also opensource? thanks
1
by: Carmen Sei | last post by:
Is there any HTTP Client library in C++ similar to what the HTTPClient Java does? http://www.innovation.ch/java/HTTPClient/
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.