I too totally agree with Partha, we cannot use singleton as servlet
themselves has one instance so when multiple user will try to access it
will create a problem

What i could think the best solution for this is calling some method on
regular intervals and updating the object which you should put in the
application scope

Cheers,
Rahul

> Singleton pattern will have problems when the web tier has multiple
> classloaders, when there may be multiple instances of the singleton. So
> take the help of the container... use an application object for stroing
> the common object and not a singleton.
> Regards,
> Partha
>
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED] Behalf Of Chris
> Pratt
> Sent: Thursday, September 01, 2005 10:13 AM
> To: SERVLET-INTEREST@JAVA.SUN.COM
> Subject: Re: Global Data
>
>
> Use the static singleton pattern to construct a States object to hold the
> static data.  Make sure it has some method to allow it to be reloaded on
> the fly.  Then add an extra web page to your web app (possibly with higher
> security) that allows you to reload the States singleton after you've
> updated the database.  Or even better have that page present you with a
> form to add the new State to both the singleton and the database in one
> fell-swoop.
>   (*Chris*)
>
>
> On 8/31/05, SUBSCRIBE EJB-INTEREST anonymous < [EMAIL PROTECTED]> wrote:
>
> Hi,
> I have a question.
> In my web application, when the user logs in, I have to load all State
> information from the database and display it.The State information will be
> common to all users.I would add new States into the database table.
> My question is what is the best way to get the state information from
> database and store it globally,so that, it can be shared by all users.
>
> If I use servlet for this, and load the state information in the init(), I
> have to restart the server whenever I add new state information to the
> database, inorder to get the new states.I don't want the server to get
> restarted whenever I add state information to database.SO, this option is
> not feasible.
> Is there any other way to do this?
>
> Any ideas/suggestions to resolve this issue would be very helpful for me.
>
> Thanks in advance.
>
> ___________________________________________________________________________
> 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
>
>
>
> ___________________________________________________________________________
> 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
>
>
>
>
>
> ___________________________________________________________________________
> 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
>
>

___________________________________________________________________________
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