hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Loosing my HttpSession between Applet and Servlet
Date Wed, 24 Mar 2010 15:13:03 GMT
On Tue, 2010-03-23 at 17:57 -0400, Deschamps.Francois.2@hydro.qc.ca
wrote:
> Hi,
>  
> I'am using HttpClient 4.0.1.
>  
> Each time my applet make a get or post to the servlet, I am loosing my httpSession on
the back end.
>  
> How can we keep the httpSession alive with HttpClient ?
>  
> Here's the call that I made from my applet, each time it is call, i get a new httpSession
from my servlet :
>  
> public static void getHttp(TestHttpSession applet) {
> 
> try {
> 
> HttpClient clientHttp = new DefaultHttpClient();
> 
> HttpResponse response = clientHttp.execute(httpGet);
> 
> HttpGet httpGet = new HttpGet(applet.getURL());
> 
> clientHttp.getConnectionManager().shutdown(); 
> 
> } catch (Exception e) {
> 
> e.printStackTrace();
> 
> }
> 
> }
> 
> Thanks,
> Frank

No wonder the HTTP session does not stick, as you are creating a new
instance of HttpClient for each request. When HttpClient instance goes
out of scope, you lose all state information contained in it.

Oleg

>  
> 
> François Deschamps
> Conseiller en TI,
> Centre d'expertise Java (DMDI)
> Hydro-Québec
> tel: 514-840-3000 (4756)
> courriel: deschamps.francois.2@hydro.qc.ca <mailto:deschamps.francois.2@hydro.qc.ca>

>  



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


Mime
View raw message