Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 78896 invoked from network); 19 Jul 2003 12:47:55 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 19 Jul 2003 12:47:55 -0000 Received: (qmail 23198 invoked by uid 97); 19 Jul 2003 12:50:26 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@nagoya.betaversion.org Received: (qmail 23191 invoked from network); 19 Jul 2003 12:50:25 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 19 Jul 2003 12:50:25 -0000 Received: (qmail 77464 invoked by uid 500); 19 Jul 2003 12:47:42 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 77451 invoked from network); 19 Jul 2003 12:47:41 -0000 Received: from sid.armstrong.com (204.74.20.252) by daedalus.apache.org with SMTP; 19 Jul 2003 12:47:41 -0000 Received: from joedog.org (pcp01470022pcs.lncstr01.pa.comcast.net [68.82.237.147]) by sid.armstrong.com (8.12.8p1/8.12.8) with ESMTP id h6JCfAM0015309 for ; Sat, 19 Jul 2003 07:41:10 -0500 Message-ID: <3F193DE9.2060401@joedog.org> Date: Sat, 19 Jul 2003 08:47:37 -0400 From: Tim Funk Organization: Human being User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en, es-mx, de, sv MIME-Version: 1.0 To: Tomcat Users List Subject: Re: How to clean objects in user's session References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Older versions of tomcat have their Enumeration from session.getAttributeNames() backed by an Iterator. So if a change is made you get the ConcurrentModificationException. I know tomcat 5 does not have this problem but I don't know about tomcat4. Since your using 4.1.24 - I am guessing the change was not backported. The easiest solution is to call invalidate - but this also usually logs the user out too so it may not be acceptable. Once a session is invalidated - it can't be used anymore for getting and setting stuff. The alternative is clone/copy the Enumeration (probably the hard way by an extra iteration) - then iterate through the copied version. The copied version has no relation to the list so you can clear its atributes without the exception. -Tim Imran Balkhi wrote: > Hello, > > Our application is divided into multiple vertical views (ie, multiple > company). User can work in only one vertical slice at a time (ie, abc > company). Currently users have to logout and login again to change the > vertical. There is a business requirement to provide ability to switch > verticals without the need to logout and relogin. Here are my options. > > > 1) invalidate the session object and create a new session. I am not sure > if this is possible with logout and relogin routine. We are using our own > authentication. > > 2) remove vertical specific objects from user's session. This option > seems to be less intrusive on users. However, I am not able to remove > objects Here is the test code > > if((userPreference.getCurrentCompanyId() > 0) && > userPreference.getCurrentCompanyId() != companyId){ > Enumeration sessionAttributes = session.getAttributeNames(); > while(sessionAttributes.hasMoreElements()) { > String name = (String) sessionAttributes.nextElement(); > if ((name.compareTo("userSession") != 0) && //exclude vertical > independent objects > (name.compareTo("style") != 0) && > (name.compareTo("moduleID") != 0) && > (name.compareTo("listNavigatorMap") != 0)) > logger.debug ("Name : " + name); > session.removeAttribute(name); > } > } > } > > I am getting ConcurrentModificationException, detials are in attached file. > > Can any one point out what am I doing wrong or let me know if there are > better ways to get to goal. > > Thanks, > Imran > > > --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org