tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastiaan van Erk <>
Subject How can I share an object between an application and its embedded tomcat?
Date Tue, 01 May 2007 09:29:31 GMT

I have an application which needs to start an embedded Tomcat en share 
an object instance with a servlet which will run in the embedded tomcat 
servlet container. One solution is to use a static field of a class, but 
I prefer a direct way to do this, without using static fields.

Currently I do this, but I don't like that either:

        // Start the embedded server

        // Set the attribute on the servlet context.
        context.getServletContext().setAttribute(MY_ATTRIBUTE, myInstance);

One reason I don't like it is because there is a short period of time 
that the attribute is not set but the server is already running.

Is there a better way to do this?


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message