isolation
JSP files and the files they import execute in isolation from all
other requests to the same files. In addition, their statements
are reevaluated for each request. The static statement lets the
developer execute a statement only once or to share information
between requests
statement is executed as soon as the file is parsed.
During subsequent requests, the statement is not reevaluated.
Requests are still isolated from
each other. All JavaScript objects created or modified in a
static statement are copied for each request. Since
wrapped Java objects are not copied,
developers can use static statements in combination with
wrapped Java objects to create application
objects.
In general, Java used as application objects will need synchronization to keep the state
consistent between request threads
<%
static {
application = new caucho.vfs.MemoryFilesystem();
application.object = 3;
}
synchronize (application) {
value = application.object++;
}
%>
<h1>You are visitor <%= value %> <h1>
|
Copyright © 1998-2000 Caucho Technology. All rights reserved.
Last modified: Thu, 16 Sep 1999 14:56:49 -0700 (PDT)
|