Hi

Either here or in c.l.j.p, in a discussion about jsp pages and scope,
someone noted that using jsp:useBean with scope="application" on the opening
page was a good way of initiating things like connection pools etc. Of
course, as I have discovered,  this doesn't work for singleton objects,
because the pattern demands that the constructor is private and thus it
can't be created as a bean by the jsp page. I've temporarily worked around
this by creating a helper class that calls the getSingleInstance() method of
my singleton within it's public constructor and using the help class with
jsp:useBean. Does the singleton class adopt application scope because it was
created by an object with scope="application" or, as I suspect, its my
helper class that now has application scope and I can expect my singleton
object to get garbage collected periodically.

What is the recommended technique for creating singleton objects with
application scope?

As an aside, is it possible to create an object whose scope is associated
with the existance of the servlet engine and therefore its existance is
independant of any application (currently active or inactive) but can be
acccessed by all applications. For example I would like to create a
singleton database connection pool when starting Tomcat that will exist
until Tomcat is shutdown, and will be accessible to any and all
applications?

Regards
Roger Varley


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

___________________________________________________________________________
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