>   Hi, I have a need to write to a file from multiple servlets,
> possibly all sending requests at the same time. So, I have an object
> which is created in the init() routine of one of my servlets, as
> follows:
> [...]
>   This is all working, pretty much. But I am confused about how to
> ensure that the object is initialized before other servlets attempt
> to use it?

     Go look up the "singleton" pattern.  The basic details are:

     give the pieLog class a private constructor

     give the class an instance variable that holds a reference to an
          instance of pieLog

     give the pieLog class a static getPieLog() method that:

          1) if the instance variable is null, calls the private
             constructor

          2) returns the object inside the instance variable,


     It's late, I'm tired, I haven't even looked at source code in a
month or two, and haven't looked at a singleton in many months, so go
read up on it.  It's been discussed many, many times.

Steven J. Owens
[EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to