Return-Path: Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@www.apache.org Received: (qmail 64459 invoked from network); 26 Aug 2004 11:42:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 26 Aug 2004 11:42:37 -0000 Received: (qmail 87331 invoked by uid 500); 26 Aug 2004 11:42:33 -0000 Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@jakarta.apache.org Received: (qmail 87245 invoked by uid 500); 26 Aug 2004 11:42:32 -0000 Mailing-List: contact commons-httpclient-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Commons HttpClient Project" Reply-To: "Commons HttpClient Project" Delivered-To: mailing list commons-httpclient-dev@jakarta.apache.org Received: (qmail 87091 invoked by uid 99); 26 Aug 2004 11:42:30 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [57.80.136.22] (HELO kccxoex16.corp.kpmgconsulting.com) (57.80.136.22) by apache.org (qpsmtpd/0.27.1) with ESMTP; Thu, 26 Aug 2004 04:42:28 -0700 Received: from kccxoex06.corp.kpmgconsulting.com ([10.98.3.31]) by kccxoex16.corp.kpmgconsulting.com with InterScan Messaging Security Suite; Thu, 26 Aug 2004 11:42:24 -0000 Received: KCCXOEX06 10.98.3.31 from 10.131.13.183 10.131.13.183 via HTTP with MS-WebStorage 6.0.6249 Received: from localhost.localdomain by KCCXOEX06; 26 Aug 2004 13:42:26 +0200 Subject: Re: RE : How to use two distinct HttpClients on the same web site From: Oleg Kalnichevski To: Commons HttpClient Project In-Reply-To: <0C046C76C7EE2C4F99BFDBE99E6A9A3338413D@brutus.twinsoft.fr> References: <0C046C76C7EE2C4F99BFDBE99E6A9A3338413D@brutus.twinsoft.fr> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-Id: <1093520546.7413.31.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Thu, 26 Aug 2004 13:42:26 +0200 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Thu, 2004-08-26 at 11:28, Fabien BALAGEAS wrote: > Thank you Oleg, >=0D > I was not able to keep the "hostconfiguration" parameter to null in >=0D > httpclient.executeMethod(null, httpget1, httpstate1); >=0D > I had to set it to httpClient.getHostConfiguration()... >=0D > In fact, i want to access the same logical web application= "http://www.whatever.com/app" on one physical server, but from two= different logical users. >=0D > When i execute your sample, httpget1 and httpget2 has the same session ID= if i connect to the same web app ("http://www.whatever.com/app"). The= cookie automatically sent by HttpClient on httpget2 is the same as the one= received from httpget1. > So the server see my two connections as if they were from the same= user... >=0D Fabien, I do not why this is happening. I would expect a well-behaved web server to redirect the request to the login page whenever the session ID cookie is not present. What web server / app server are you using? A debug/wire log of the HTTP session might help pinpoint the problem. Please refer to the HttpClient logging guide for details on how to activate the wire/debug logging http://jakarta.apache.org/commons/httpclient/logging.html Please do take time to obfuscate security sensitive information in the log, such as authentication credentials, prior to posting it to the list =0D Oleg > How to handle that??? I mean: is there a way to tell to HttpClient to= maintain distinct cookies on distinct state? >=0D > Fabien >=0D >=0D > -----Message d'origine----- > De : Oleg Kalnichevski [mailto:oleg.kalnichevski@bearingpoint.com]=0D > Envoy=C3=A9 : jeudi 26 ao=C3=BBt 2004 10:50 > =C3=80 : Commons HttpClient Project > Objet : Re: How to use two distinct HttpClients on the same web site >=0D >=0D >=0D > Fabien, >=0D > If all you need is to maintain a distinct conversational state per= logical web application hosted on the same physical platform, you should= have just only one HttpClient instance and then keep different HttpState= instances per web application. It does take a bit of HttpState juggling,= but the benefit of such setup will be a better overall performance, as= HttpClient would be able to reuse physical connections to the host. >=0D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > HttpClient httpclient =3D new HttpClient(); >=0D > HttpState httpstate1 =3D new HttpState(); > GetMethod httpget1 =3D new GetMethod("http://www.whatever.com/app1"); > try { > httpclient.executeMethod(null, httpget1, httpstate1); > System.out.println(httpget1.getStatusLine());=0D > System.out.println(httpget1.getResponseBodyAsString()); > httpstate1.getCookies(); > } finally { > httpget1.releaseConnection(); > } >=0D > HttpState httpstate2 =3D new HttpState(); > GetMethod httpget2 =3D new GetMethod("http://www.whatever.com/app2"); > try { > httpclient.executeMethod(null, httpget2, httpstate2); > System.out.println(httpget2.getStatusLine());=0D > System.out.println(httpget2.getResponseBodyAsString()); > httpstate2.getCookies(); > } finally { > httpget2.releaseConnection(); > } > =0D > Hope this helps >=0D > Oleg >=0D > On Thu, 2004-08-26 at 08:46, Fabien BALAGEAS wrote: > > Hi, > > =0D > > I am using HttpClient 2.0.1. > > =0D > > I would like to have two HttpClient connections to the same web site=0D > > in my application, but from two "distinct" HttpClient (i.e. each=0D > > connection should handle its self cookies). > > =0D > > How can i realize this task ? > > =0D > > Up to now, i only managed to have two connections to the web site, but= =0D > > with the same cookies sent, so the web site see my two connections as=0D > > if they were one. > > =0D > > Thanks in advance for your help, > > Fabien > > =0D >=0D >= **************************************************************************= ************************* > The information in this email is confidential and may be legally= privileged. Access to this email by anyone other than the intended= addressee is unauthorized. If you are not the intended recipient of this= message, any review, disclosure, copying, distribution, retention, or any= action taken or omitted to be taken in reliance on it is prohibited and= may be unlawful. If you are not the intended recipient, please reply to= or forward a copy of this message to the sender and delete the message,= any attachments, and any copies thereof from your system. >= **************************************************************************= ************************* >=0D > --------------------------------------------------------------------- > To unsubscribe, e-mail:= commons-httpclient-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail:= commons-httpclient-dev-help@jakarta.apache.org >=0D >=0D > --------------------------------------------------------------------- > To unsubscribe, e-mail:= commons-httpclient-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail:= commons-httpclient-dev-help@jakarta.apache.org ***************************************************************************= ************************ The information in this email is confidential and may be legally= privileged. Access to this email by anyone other than the intended= addressee is unauthorized. If you are not the intended recipient of this= message, any review, disclosure, copying, distribution, retention, or any= action taken or omitted to be taken in reliance on it is prohibited and= may be unlawful. If you are not the intended recipient, please reply to= or forward a copy of this message to the sender and delete the message,= any attachments, and any copies thereof from your system. ***************************************************************************= ************************ --------------------------------------------------------------------- To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org