On Tue, 2010-03-23 at 17:57 -0400, [email protected]
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: [email protected] 
> <mailto:[email protected]> 
>  



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to