No offense, but writing to a file is a horrible idea. Why don't you just implement a checking mechanism in the servlet context object that makes sure you get the correct data for the sessions you are trying to share data between? It doesn't necessarily have to be available to everyone. Just make sure your code does the necessary checks before handing the data out.
Is it safe to assume yu have two sessions because ur application consists of more than one war file? Is that the case?
SCJP 1.4, SCWCD 1.4
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler et al, Refactoring: Improving the Design of Existing Code, 1999
It would be helpful if you explained more about the context of the two sessions. Do you envisage both sessions being for the same user, perhaps the second being created when the user logs on after the first one times out?
If so, it would make sense to store the preferred colour for each user in a database so that it can be retrieved when subsequent sessions are created for the same user.
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad: