I think I know the answer to this, but I would like reassurance.
I'm building a timesheet application using JSP, servlets, and Tomcat. So far, I been
very careful to keep all non-contant data out of servlet class instance variables so
everything should be thread safe and there should be no
: Sharing among session of ONE application
I think I know the answer to this, but I would like reassurance.
I'm building a timesheet application using JSP, servlets, and Tomcat. So
far, I been very careful to keep all non-contant data out of servlet class
instance variables so everything should
Howdy,
Now, I've got some information I WOULD like to share across all
sessions of
the application (but not across other Tomcat applications). So, that
should mean that all I really have to do is defined the information in
instance variables (and remember when using it that it can change
So, that should mean that all I really have to do is defined the information in instance variables. Right?
There is however an important risk related to this approach.
AFAICT, you are not guaranteed that there is a SINGLE instance of each
servlet. It will be implementation-dependent.
So,
If the data is truly once only for the entire application, I'd write a
singleton and have the applications each access that. You can control
race conditions to start by synchronizing the methods of the singleton
and later optimize the performance by removing the synchronization
there and instead