Using a singleton for sharing data between web applications is prone to error. Singleton's are only unique per classloader and the Servlet Spec (at least the 2.2 spec) only specifies that each web application must have its own classloader for instances created from the Web-Inf/classes and Web-Inf/lib directories. Thus, if the singleton implementation class file is located in these directories, each web application will have a reference to a distinct instance.
In Tomcat, you may place the class file in classpath directory that spans all applications - lib/container for example. Any instance created from the shared classpath will be loaded by a single classloader regardless of the web application. However, you should note that servlet container classpath directories differ across implementations and you may not receive the desired behavior in another servlet container. ----- Original Message ----- From: "reunionf" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, April 26, 2002 9:00 AM Subject: Re: share data between 2 and more webapp > Hi guys and girls, > > You can use a singleton. this pattern is described on the site java.sun.com > > bye > > ----- Original Message ----- > From: "Yuriy Stepovoy" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, April 26, 2002 1:03 PM > Subject: share data between 2 and more webapp > > > > Hello ALL. > > > > can anyone explain how share data between 2 and more webapp existed in > servlet > > container ? > > > > > > -- > > Best regards, > > Yuriy > > > > > ___________________________________________________________________________ > > 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
