tomcat-users mailing list archives

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

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
        embedded.start();

        // 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?

Regards,
Sebastiaan


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message