You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Ryan <sa...@163.com> on 2007/07/31 10:06:30 UTC

Strange Exception: host parameter is null

hi, everyone, 
about two days, I muded in a strange problem. I use four method which are post, get, get, post, first three is ok, but the fourth  method trigger a Exception: host parameter is null. 
The exception occurs from HttpConnection.setHost(1); 
SimpleHttpConnectionManager.getConnectionWithTimeout(2);
HttpMethodDirector.executeMethod(3);
HttpClient.executeMethod(4)
GetMailList.PostData(5)   // this is my code
here is my main function: 
	GetMaillist list = new GetmailList("http://mail.insun.hit.edu.cn");
	NameValuePair[] data = {....}
	String response = list.PostData(url, data); // PostData is like a PostMethod, post data to a 											// 	//appointed web page.
	// response get the Logon's response String
	List<String> urls = list.getUrl(response); //extract url frm the response html message
	for(int i =0 ; i < urls.size(); i++) {
		list.ReadMailList(urls.get(i));     //ReadMailList like a GetMethod, get the response message from
                                       // the appointed url
	}

	NameValuePair[] markdata = {.....};
	resoponse = list.PostData(url + "...", markdata);
	
the first three are work properly, only the fourth got a exception.Below is the PostData function
public String PostData(String url, NameValuePair[] data) {
	PostMethod post = new PostMethod(url);
	post.setRequestBody(data);
	post.getParams().setBooleanParameter("http.protocol.single-cookie-header", true);
	try {
		int statusCode = client.executeMethod(post);   // client is a member of GetMailList Class
		String response = null;
		response = post.getResponseBodyAsString();
	}catch(){......
	}
}






Ryan
2007-07-31



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re:Re: Strange Exception: host parameter is null

Posted by sandacn <sa...@163.com>.
 Hi, Roland I got the problem's answer: the url is error, when I add the url as :"host + url" is OK. Thanks for your replying. Ryan    
在2007-08-01,"Roland Weber" <os...@dubioso.net> 写道:
Hi Ryan, > the fourth method trigger a Exception: host parameter is null. Please post a stack trace of this exception. Without that, we can only guess where you are seeing the problem. > the first three are work properly, only the fourth got a exception.Below is the PostData function > public String PostData(String url, NameValuePair[] data) { > PostMethod post = new PostMethod(url); What value has 'url' here? Is it an absolute URL? cheers, Roland --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

Re: Strange Exception: host parameter is null

Posted by Roland Weber <os...@dubioso.net>.
Hi Ryan,

> the fourth  method trigger a Exception: host parameter is null. 

Please post a stack trace of this exception. Without that,
we can only guess where you are seeing the problem.

> the first three are work properly, only the fourth got a exception.Below is the PostData function
> public String PostData(String url, NameValuePair[] data) {
> 	PostMethod post = new PostMethod(url);

What value has 'url' here? Is it an absolute URL?

cheers,
  Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org