tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Want to customise the tomcat's session logic
Date Tue, 10 Nov 2009 20:52:28 GMT
Hash: SHA1


On 11/9/2009 9:55 PM, André Warnier wrote:
> Christopher Schultz wrote:
>> I wish you'd tell us what the heck you're trying to do because I'm
>> certain there's an easier way to do it.
> Like maybe just add an attribute to the session, containing the path
> where the session was begat ?
> (if I remember the original exposé correctly)

I was thinking of something even slightly more brute-force-y like:

Write a filter (my favorite!) that you map multiple times to your
webapp, once for each URI segment that represents the old, separate webapps.

The filter wraps the request which wraps HttpSession objects handed-out
by the requests. The HttpSession wrapped is configured with the URI
segment from the old webapp and basically represents a prefix used to
prepend to all session keys. The HttpSession object you get from the
wrapper only gives you access to keys that have the proper prefix.

So, the "real" session has data like:

"/oldWebappA:foo" -> "This is a string from the old 'A'"
"/oldWebappB:foo" -> "This is a string from the old 'B'"

When the code from "oldWebappA" requests the value for the key "foo",
the wrapped HttpSession prepends "/oldWebappA:" to the beginning of the
key and returns "This is a string from the old 'A'". When the code from
"oldWebappB" does the same, it gets "This is a string from the old 'B'".

You can also go crazy and use a search order like:

a. If URI + key has a value, return that
b. else, return value for just the bare key

This would allow sessions to share /some/ data, but everything else
would be segmented.

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message