Return-Path: Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: (qmail 79686 invoked from network); 16 Jul 2008 23:19:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Jul 2008 23:19:13 -0000 Received: (qmail 24545 invoked by uid 500); 16 Jul 2008 23:19:12 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 24524 invoked by uid 500); 16 Jul 2008 23:19:12 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 24508 invoked by uid 99); 16 Jul 2008 23:19:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jul 2008 16:19:12 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lsborle@gmail.com designates 74.125.92.148 as permitted sender) Received: from [74.125.92.148] (HELO qw-out-1920.google.com) (74.125.92.148) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jul 2008 23:18:19 +0000 Received: by qw-out-1920.google.com with SMTP id 5so413157qwf.10 for ; Wed, 16 Jul 2008 16:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=6dvXrwWuOmHJl3y2h0jQp14fJLh92zsKOBqwNFh+avg=; b=S7TyBfwVGcmm5bwHt/g11eErkWqXeO8ips1PcsbuGoOVcJdnQOFt3iv7L219YWPilE 7LobSXQvmlUMlfnBA2+6qdgUIql34eIsSPlFijYFGiXiyfzJ+RhpnVYOuDsDfdYCanyA EMA1pWwjULEOIGgYku1KM5clQ9Tb52t0ToKkc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=w+kEHBP1+gULYcgtIJy8U9XUuArIuOK91pGkHyWaOcNpVgyEXCar3MK97StbDoM7/u V0MAt+M5jKQyILfIHxiPnW8pXWH67w4dERVkFJFZdHfiMKCSB3g+8Yw+WXMrb5hQF4I/ vRcp2W2f14KVmKrgMTF7eTVS7BX94uUlnMINY= Received: by 10.115.50.5 with SMTP id c5mr998571wak.192.1216250322609; Wed, 16 Jul 2008 16:18:42 -0700 (PDT) Received: by 10.114.179.20 with HTTP; Wed, 16 Jul 2008 16:18:42 -0700 (PDT) Message-ID: <9e154a080807161618r102bd921u53c70bb4a64cbb2a@mail.gmail.com> Date: Wed, 16 Jul 2008 16:18:42 -0700 From: "Leena Borle" To: httpclient-users@hc.apache.org Subject: HttpClient invalidates session MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_40215_14611895.1216250322593" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_40215_14611895.1216250322593 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I have a struts-2 application running on Tomcat-5 with Single Sign on enabled. What I am trying to do is , use HttpClient(struts2 app) to access data other WAR(say WAR2) which also has Form Based login system. To avoid sending user's credentials(Which I don't have in my application), I am trying to send cookie-JSESSIOIDSSO in the request header. Everything works fine, I get the data back. But after that, my application throws error that, session is invalidated. How do I stop HttpClient from invalidating the session ? Thanks Leena. Here is the code in my application , (Struts-2) HttpServletRequest request = ServletActionContext.getRequest(); //try out httpclient javax.servlet.http.Cookie[] cookies = request.getCookies(); HttpState newState = new HttpState(); javax.servlet.http.Cookie ssoID = null; for(int c = 0; c < cookies.length; c ++) { javax.servlet.http.Cookie k = cookies[c]; if(k.getName().equalsIgnoreCase("JSESSIONIDSSO")) ssoID=k; } HttpClient client = new HttpClient(); client.setState(newState); GetMethod getMethod = new GetMethod(" http://localhost:8080/war2/exceuteServlet"); getMethod.getParams().setCookiePolicy(org.apache.commons.httpclient.cookie.CookiePolicy.IGNORE_COOKIES); getMethod.setRequestHeader("Cookie", ssoID.getName() + "=" + ssoID.getValue()); try { int responseCode = client.executeMethod(null,getMethod,newState); String body = getMethod.getResponseBodyAsString(); AppLogger.getLogger().debug("Response code = " + responseCode+ " \nResponse is " + body); } catch (HttpException e) { // TODO Auto-generated catch block } catch (IOException e) { // TODO Auto-generated catch block } finally { // release any connection resources used by the method getMethod.releaseConnection(); } ------=_Part_40215_14611895.1216250322593--