tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Imran Balkhi" <im...@sibisoft.com>
Subject How to clean objects in user's session
Date Sat, 19 Jul 2003 02:12:16 GMT
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


Mime
View raw message