"Young, Wayne" wrote:
> 
> Ok, that gets me closer.  I created the servlet & put the following code in
> the init() method.
> 
> // Store the lookup service in the servlet context
>    LookupService lookupService = new LookupService();
>    getServletContext().setAttribute("LookupService",lookupService);
> 
> I need to get access to this attribute in a class that has nothing to do
> with servlets. Is there a method call I can make?

Not really no, you might want to look up the definition of the
single design pattern. I don't have the references here, but the
basic idea is to not create the object as you done about but have

        LookupService lookupService = LookupService.getInstance();

and then

        public class LookupService {

                private static LookupService instance = null;

                public LookupService getInstance() {
                        if (instance == null)
                                instance = new LookupService();

                        return instance;
                }
        }

so you can grab the objcet any where and be assured there is
only one instance that you are sharing. You of course then need
to make sure that the methods are synchroni(s|z)ed.

Reply via email to