tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Want to customise the tomcat's session logic
Date Tue, 10 Nov 2009 20:52:28 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkr50owACgkQ9CaO5/Lv0PBPfgCePjtorZAbO159mYG6FR+JSoGN
/7oAnRJ1WSS6t73jk1SgcvHOK0jLj2YW
=kKky
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message