The technique that Kimerly describes works well in many environments.  In
a Servlet2.3 environment (such as Tomcat 4), you also have the option to
use an application event listener that is notified when the application is
started, and when it is being shut down.  For more information, see the
Servlet 2.3 specification at:

  http://java.sun.com/products/servlet/download.html

Craig McClanahan


On Thu, 13 Sep 2001, MacKellar, Kimberly wrote:

> Date: Thu, 13 Sep 2001 16:38:12 -0500
> From: "MacKellar, Kimberly" <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> Subject: RE: Application scope objects
>
> I created a servlet that is loaded at server initialization by including the
> following in web.xml
>
>   <servlet>
>     <servlet-name>Initialization</servlet-name>
>     <servlet-class>com.tfp.fraudban.InitializationServlet</servlet-class>
>     <load-on-startup>1</load-on-startup>
>   </servlet>
>
> and in the init method of InitializationServlet I make a call like
>
> getServletContext().setAttribute("returnTypes", list);
>
> which saves an ArrayList list into the attribute returnTypes in the
> servlet's context.  list is being populated by some calls to the database.
>
> Kim
> -----Original Message-----
> From: Debasish Ghosh [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 13, 2001 4:24 PM
> To: [EMAIL PROTECTED]
> Subject: Application scope objects
>
>
> Hi All -
>
> In my application, I would like to cache some of the
> objects at the application scope in order to reduce
> database access. What is the most recommended way of
> achieving this in Struts ? Should I make them members
> of OurActionServlet, which is derived from
> ActionServlet ?
>
> Please suggest.
>
> Regards.
>
> - Debasish
>
> __________________________________________________
> Terrorist Attacks on U.S. - How can you help?
> Donate cash, emergency relief information
> http://dailynews.yahoo.com/fc/US/Emergency_Information/
>

Reply via email to