Hi,
i have done some thing like this,
I have a servlet which is loaded while starting the
application, in the init method of this servlet i load
a table and put it in servlet context,
ServletContext oCtx = config.getServletContext();
oCtx.setAttribute("MyTable", myTable);
and then in your Action class u can do the following
MyTable table =
(MyTable)this.getServlet().getServletContext().getAttribute("MyTable")
;
Ashish
--- Geeta Ramani <[EMAIL PROTECTED]> wrote:
> Larry:
>
> An easy way to do this would be to:
>
> 1. Write a controller class which extends the Struts
> ActionServlet.
> 2. Declare a *static* object of type (say) Hashtable
> in this controller.
> 3. In the init() method of the controller, write
> code to initialise this hashtable.
> 4. Finally make the appropriate markings in your
> web.xml so that your controller (rather than the
> Struts' ActionServlet) is what is called with a
> url-pattern of *.do and make sure the controller has
> a load-on-startup param as 1.
> 5. In your Action classes, you can then access this
> object in the normal way: MyController.myHashtable.
>
> Hth!
> Regards,
> Geeta
>
> Larry Hytail wrote:
>
> > I have a table of information contained in a
> backend database. The table is not very big and
> never will be. I would like to create an object
> that holds the values from this table. I would like
> this object to instantiate when the struts webapp is
> started. Then I would like to be able to access
> this object from any Action object within my struts
> application. Questions:
> >
> > 1) Where is the best place to put the
> instantiation of this object?
> >
> > 2) How do I get a handle on the object from the
> Action object?
> >
> > Larry Hytail
> >
> > ---------------------------------
> > Do you Yahoo!?
> > Yahoo! Tax Center - forms, calculators, tips, and
> more
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
=====
A$HI$H
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]