SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 129 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

The following
is a list of the things you should remember when developing a Web application
that might be deployed in a clustered environment.
1. Avoid instance variables and static data (such as singletons) for
shared data. Each JVM in a cluster will have its own copy of the
instance variables and static data. Changes to this data in one JVM will
leave all other JVMs unaffected. However, if you are certain that the
static data never changes throughout the execution of your Web app,
it??™s perfectly fine to use static data (and singletons) to share data
Chapter 2 ?–  Controlling Web Application Behavior with web.xml 96
among the resources in your Web application (not different deployments
on different machines in the cluster). In this case, it doesn??™t
matter that each JVM has its own copy of this data because it would be
the same on all machines in the cluster.
2. Don't store data in the ServletContext. Each JVM in a cluster
has its own copy of the ServletContext. Therefore, if you store an
attribute in the ServletContext, the ServletContext object of
other servers (JVMs) will not contain this attribute. However, you can
use the ServletContext to share data that is guaranteed to stay
unchanged among the resources in your Web application (not different
deployments on different machines in the cluster). This data
would have to be placed into the ServletContext immediately at
startup of the Web application.


Pages:
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141