On Wed, 2008-12-10 at 23:09 +0100, Roger Schefer wrote:
> Hi all,
> 
> I am using httpclient 3.1 in a servlet to check if a URL is alive or not. 
> When should I best initialize HttpClient? I was thinking to create a 
> HttpClient instance in the servlet constructor and to execute a HeadMethod 
> in the doGet method of the servlet. Is this the right way to do it 

Yes, it is. Make sure to use a threading safe connection manager with
HttpClient, though.


> or 
> should I better create a new instance of HttpClient in doGet for each 
> request?
> 
> Also, I want the HeadMethod to stop after a certain amount of time. How 
> can I set a timeout? I am using 
> HttpClient.getHttpConnectionManager().getParams().setConnectionTimeout(timeOut)
>  
> and 
> HttpClient.getHttpConnectionManager().getParams().setSoTimeout(timeOut), 
> but there is also HttpClient.getParams().setSoTimeout(timeOut), 
> HttpClient.getParams().setParameter("http.socket.timeout", new 
> Integer(timeOut)), 
> HttpClient.getParams().setConnectionManagerTimeout(timeOut), 
> HeadMethod.getParams().setParameter("http.socket.timeout", new 
> Integer(timeOut)) and 
> HostConfiguration.getParams().setParameter("http.socket.timeout", 
> timeOut). What is the difference between them?
> 

Please refer to the HttpClient preference architecture guide.

Oleg 


> Many thanks for any help!


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to