Mike
Divakar Satyanarayan wrote:
The first thing I did was to run the sample code PostXML.java. But it gave
me a run time exception
Exception in thread "main" java.lang.IllegalArgumentException: host
parameter is null
at
org.apache.commons.httpclient.HttpConnection.<init>(HttpConnection.java:217)
at
org.apache.commons.httpclient.HttpConnection.<init>(HttpConnection.java:145)
at
org.apache.commons.httpclient.SimpleHttpConnectionManager.getConnection(Simp
leHttpConnectionManager.java:118)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:541)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:474)
at PostXML.main(PostXML.java:268)
Once the host configuration is done I could see the host & port to which it
is configured. But I am puzzled by the above exception when exceuteMethod is
invoked.
Are there any leads to the solution for the above problem.
Divakar
-----Original Message-----DISCLAIMER: Information contained and transmitted by this E-MAIL is
From: Michael Becke [SMTP:[EMAIL PROTECTED]]
Sent: Friday, January 31, 2003 7:36 PM
To: Commons HttpClient Project
Subject: Re: java.net.UnknownHostException
Please take a look at the following URL as an example of how to use HttpClient to read from a server:
http://cvs.apache.org/viewcvs/jakarta-commons/httpclient/src/examples/ BasicAuthenticatonExample.java?rev=1.3&content-type=text/vnd.viewcvs- markup
It seems that the problem is that you are attempting to read directly from an HttpConnection. Though this seems logical given how the java.net.UrlConnection works, HttpClient handles things a little differently. All posts, gets, etc. are done via HttpMethods like PostMethod and GetMethod. HttpConnection is not meant to be used directly.
Mike
On Friday, January 31, 2003, at 07:32 AM, Divakar Satyanarayan wrote:
Hi,
I am using HTTPConnection to get a connection to an URL. It works fine when
I give just the IP address but when I specify the full path it gives me
following exception
java.net.UnknownHostException: 201.173.335.213/xxxx/xxxxx
at java.net.InetAddress.getAllByName0(InetAddress.java:571)
at java.net.InetAddress.getAllByName0(InetAddress.java:540)
at java.net.InetAddress.getByName(InetAddress.java:472)
at java.net.Socket.<init>(Socket.java:100)
at
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.cre ateSo
cket(DefaultProtocolSocketFactory.java:104)
at
org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:4 88)
at TrialConnectionClient.main(TrialConnectionClient.java:237).
What am I missing ? I've pasted the code
HttpConnection oHttpConnection = new
HttpConnection(strURL,440);
logMessage("Connected before"+
oHttpConnection.isOpen() );
logMessage("Connected before"+
oHttpConnection.getProxyHost());
logMessage("Connected before"+
oHttpConnection.getPort());
oHttpConnection.open();
logMessage("Connected after"+
oHttpConnection.isOpen() );
RequestOutputStream oRequestOutputStream = new
RequestOutputStream(oHttpConnection.getRequestOutputStream(),false);
logMessage("Output Stream ");
strXml = "inputXml="+sbInputXML.toString();
oRequestOutputStream.println(strXml);
//oRequestOutputStream.close();
logMessage(" Input Stream ");
BufferedReader oBufferedReader = new
BufferedReader(new
InputStreamReader(oHttpConnection.getResponseInputStream()));
logMessage("Opening the input Stream");
String line;
System.out.println(System.currentTimeMillis());
logMessage("Buffered Input starting to read");
while ((line = oBufferedReader.readLine()) != null)
{
System.out.println(line);
sbXMLText.append(line + "\n");
}
DISCLAIMER: Information contained and transmitted by this E-MAIL isRegards, Divakar ___________________________ DIVAKAR SATYANARAYAN +91-80-5521701-6 Ext : 1018
proprietary to Mascot Systems Limited and is intended for use only by the
individual or entity to which it is addressed, and may contain information
that is privileged, confidential or exempt from disclosure under applicable
law. If this is a forwarded message, the content of this E-MAIL may not have
been sent with the authority of the Company. If you are not the intended
recipient, an agent of the intended recipient or a person responsible for
delivering the information to the named recipient, you are notified that any
use, distribution, transmission, printing, copying or dissemination of this
information in any way or in any manner is strictly prohibited. If you have
received this communication in error, please delete this mail & notify us
immediately at [EMAIL PROTECTED] Before opening attachments,
please scan for viruses.
---------------------------------------------------------------------
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]
proprietary to Mascot Systems Limited and is intended for use only by the
individual or entity to which it is addressed, and may contain information
that is privileged, confidential or exempt from disclosure under applicable
law. If this is a forwarded message, the content of this E-MAIL may not have
been sent with the authority of the Company. If you are not the intended
recipient, an agent of the intended recipient or a person responsible for
delivering the information to the named recipient, you are notified that any
use, distribution, transmission, printing, copying or dissemination of this
information in any way or in any manner is strictly prohibited. If you have
received this communication in error, please delete this mail & notify us
immediately at [EMAIL PROTECTED] Before opening attachments,
please scan for viruses.
---------------------------------------------------------------------
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]