473,806 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Having problem in org.apache.comm ons.httpclient. methods.PostMet hod?? ??

58 New Member
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.getParam s().setCookiePo licy(CookiePoli cy.BROWSER_COMP ATIBILITY);

String userAgent="Mozi lla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
String connection="Kee p-Alive";

PostMethod postMethod = new PostMethod("url ");
postMethod.addR equestHeader("U ser-Agent",userAgen t );
postMethod.addR equestHeader("C onnection", connection);
HttpConnectionM anager connectionManag er = client.getHttpC onnectionManage r();
connectionManag er.getParams(). setConnectionTi meout(8000);

NameValuePair[] nameValue =new NameValuePair[3];
nameValue[0]=new NameValuePair(" username","xxxx x");
nameValue[1]=new NameValuePair(" password","xxxx x");
nameValue[2]=new NameValuePair(" submit1","OK");
postMethod.setR equestBody(name Value);
int status=client.e xecuteMethod(po stMethod);
StringTokenizer st1 =
new StringTokenizer (postMethod.get ResponseBodyAsS tring());


regards,
sundar
Feb 7 '08 #1
0 3749

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

Similar topics

1
47616
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 java1.4.2_04 (JIT: null) My Java version is:
0
3793
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 it into the designated folders in the server.When I run the Java client, I get the response Status = 200 and also uploaded replies from the Perl script but when I checked in the folder, the XML file is 0 KB. I am not sure what went wrong. Spending a...
4
3195
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 will crash. Can anyone explain to me why? I don't want session_start to be at the start of the file because I need to override some session methods. So session_start has to happen after the declaration of custom session methods. Can anyone...
3
3306
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 current session cookie in the headers using $headerArray = array("Cookie: " . session_name() . "=" . session_id());
4
13995
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 provided with 'AXIS'. Later ,I wanted to run a 'build.xml' file created of my own to run the 'example3' project under a diffrent directory and configured the 'build.xml' accordingly. I succeded but after then .. I could not run any of the...
1
3254
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 code that included:
0
1949
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 example how much bytes just downloaded / uploaded, how much bytes remain to end, speed (in KB/ s), progress, time left (time remain) (in seconds) Documentation is in rar file (HttpClient.dll + Documentation.html). Unfortunately the documentation...
5
1734
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
3398
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
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10624
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5684
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3853
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.