Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 33977 invoked from network); 14 May 2008 17:35:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 May 2008 17:35:09 -0000 Received: (qmail 18217 invoked by uid 500); 14 May 2008 17:34:59 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 17994 invoked by uid 500); 14 May 2008 17:34:58 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 17983 invoked by uid 99); 14 May 2008 17:34:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 May 2008 10:34:58 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [76.96.30.48] (HELO QMTA05.emeryville.ca.mail.comcast.net) (76.96.30.48) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 May 2008 17:34:02 +0000 Received: from OMTA13.emeryville.ca.mail.comcast.net ([76.96.30.52]) by QMTA05.emeryville.ca.mail.comcast.net with comcast id RUX21Z00417UAYkA502x00; Wed, 14 May 2008 17:34:05 +0000 Received: from [192.168.1.121] ([68.55.225.178]) by OMTA13.emeryville.ca.mail.comcast.net with comcast id RVaL1Z00A3ra03G8Z00000; Wed, 14 May 2008 17:34:21 +0000 X-Authority-Analysis: v=1.0 c=1 a=cTpPZGfo3_oA:10 a=r3TMSCAl4rMA:10 a=xe8BsctaAAAA:8 a=vH6djfid1dVBbY9rtgQA:9 a=kZUE7jciXnP1DGviP4UA:7 a=1QHY_Vu7HT2rtDA5GftADgsPZgEA:4 a=rPt6xJ-oxjAA:10 Message-ID: <482B229C.6020906@christopherschultz.net> Date: Wed, 14 May 2008 13:34:20 -0400 From: Christopher Schultz User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Preventing tomcat from creating sessions References: <5731c9590805140936n7177018dwb247c2cee838f92d@mail.gmail.com> In-Reply-To: <5731c9590805140936n7177018dwb247c2cee838f92d@mail.gmail.com> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Youssef, Youssef Mohammed wrote: | I am writing a set of RESTful services. client do not send cookies and we | don't want to user URL rewriting for most | of the services (they are just stateless). | The issue is when the client calls http://localhost/services/resource say | n times, the application server/servlet container creates n sessions ! | How do i prevent that from happening ? AFAIK, Tomcat does not create a session unless the code you are running requests a session to be created. Are you using JSPs? Do they have session="false" set in them? What about other code that might be calling request.getSession(true) or request.getSession()? You should be able to find the cause of the sessions being created AND prevent them from actually being created by using a filter like this: public void doFilter(ServletRequest request, ~ ServletResponse response, ~ FilterChain chain) { ~ if(request instanceof HttpServletRequest) ~ request = new SessionKillingRequest((HttpServletRequest)request); ~ chain.doFilter(request, response); } public class SessionKillingRequest ~ extends HttpServletRequestWrapper { ~ public SessionKillingRequest(HttpServletRequest request) ~ { ~ super(request); ~ } ~ public HttpSession getSession(boolean create) ~ { ~ if(create) ~ { ~ new Throwable("Attempted session creation").printStackTrace(); ~ } ~ return null; ~ } } This will print a stack trace indicating where your code is requesting a session, and it should prevent the creation of those sessions. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkgrIpwACgkQ9CaO5/Lv0PDTowCgoHCYiOjNxjivyK74ODBjqCL7 7mQAnjd2L55aYlRhT+dFnEXyTZWVn2Pw =5dsM -----END PGP SIGNATURE----- --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org