You can make the ServletContext an attribute of the object you're binding. Of course, that won't work in a distributed environment, but hey, the entire scheme won't work in a distributed environment anyway.
If your container supports
servlet 2.3 then you can simply use a HttpSessionListener. It is much simpler and non-invasive: you would set it up in the web.xml file without modifying any existing code.
- Peter