Zachariah wrote:

> What is the "proper" way to implement non-servlet singleton components in
> the Tomcat framework?

This type of discussion is better handled on the TOMCAT-USER list, because it
does not relate to the development of Tomcat.

>
> Looking over the docs, it was talking all about
> servlets as components, and there didn't seem a way to have an object
> instantiated and persistent while the jvm was running, and have that
> object accessible to the servlets.

The typical way to implement singletons in a web application is to use Java
static variables and methods.  Such statics are unique within the scope of a
class loader, and each web application has its own class loader -- so the
singleton is "global" with respect to the web app it is defined in and does
not interfere with any other web apps in the same Tomcat environment.

For global resources that are not necessarily singletons, you should look at
using servlet context attributes, which are accessible from any servlet (via
getServletContext().getAttribute()) and are also accessible to JSP pages as
"application scope" beans.

Craig McClanahan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to