Re: Global Data

Rahul Juneja <[email protected]> Thu, 1 Sep 2005 02:50:05 -0400
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
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 Servle=
t
> API Technology. [mailto:[email protected]]On Behalf Of Chri=
s
> Pratt
> Sent: Thursday, September 01, 2005 10:13 AM
> To: [email protected]
> Subject: Re: Global Data
>
>
> Use the static singleton pattern to construct a States object to hold t=
he
> static data.  Make sure it has some method to allow it to be reloaded o=
n
> the fly.  Then add an extra web page to your web app (possibly with hig=
her
> 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 m=
e.
>
> 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 bo=
dy
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