Craig McClanahan wrote:
On Apr 8, 2005 11:28 AM, Dave Newton <[EMAIL PROTECTED]> wrote:If the servlet is just putting objects into application scope does this matter?
The servlet container is *not* required to leave your load-on-startupI haven't done much (anything?) with servlet listeners--what's the advantage to doing it this way as opposed to a servlet.init that loads on app startup? Generally what we've done is to have a thread that checks a flag that signals DB changes that then calls the same code to reload everything. I'm not too involved with that part of the code though.
servlet loaded for the entire duration of the webapp's lifetime
(although, in practice, most containers do). For example, the
container could unload a servlet that it sees isn't being used, or if
it has memory contention issues, or for whatever reason is desired.
We weren't using the same servlet to reload that app-scoped data (don't ask; I don't know) but even if we were, would the only penalty be time? IOW, the servlet isn't "gone forever," right?
A ServletContextListener, on the other hand, guarantees thatI think I'll move all this stuff over to there anyway; that sounds much cleaner.
contextInitialized() will get called at startup time (before any
requests have been processed), and contextDestroyed() will get called
at shutdown time (after the last request), no matter what happens in
between.
Thanks!
Dave