Bob, I had static variable before, will try ServletContextListener Thanks
On Sun, Jul 11, 2010 at 7:49 PM, Bob Schellink <[email protected]> wrote: > On 12/07/2010 09:16, Andrei wrote: >> >> I don't understand >> How would I initialize cache (for GAE Memcache) variable once per >> servlet creation > > > So you want two caches? One for each Servlet or just a single global cache? > > > so I can use it in my Page? >> From what I understand new Page is created per each request. > > Why not store the cache as an attribute in the ServletContext? Or even a > static variable? Another > common approach is to use a Filter and a ThreadLocal. For each request you > can inject the cache into > the ThreadLocal and remove it afterwards. And your page can still access the > cache from the > ThreadLocal in a static way. > > Kind regards > > Bob >
