struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: Meta Information in Action Form
Date Fri, 08 Apr 2005 18:40:00 GMT
On Apr 8, 2005 11:28 AM, Dave Newton <newton@pingsite.com> wrote:
> Matt Raible wrote:
> 
> > As far as drop-downs, I typically populate all (or most) of mine from
> > a  database at application startup using a ServletListener.  I stuff
> > these  into the application scope as Lists of LabelValue beans.  Then
> > I code  up a ReloadAction that can call my Listener to reload them
> > all.  I've  found this useful so I don't have to restart the app if
> > data changes.   If I have edit screens for the drop-downs, I'll
> > replace the List in  application scope after saving.
> 
> I 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.
> 

The servlet container is *not* required to leave your load-on-startup
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.

Of course, if you're talking about ActionServlet, it will get reloaded
again on the next request, but that will cause your init() method to
run again -- wasting a whole bunch of time in many cases.

A ServletContextListener, on the other hand, guarantees that
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.

Craig


> (We store a LOT of information in the DB as we do not have access to the
> production servers. The more we keep in the DB the better off we are. I
> even keep some Jython scripts in there and almost had them convinced to
> keep classes, but sanity prevailed :)
> 
> Dave
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message