iTP Secure WebServer System Administrator's Guide (iTPWebSvr 5.1+)

Using NonStop Servlets for JavaServer Pages With
The iTP Secure WebServer
iTP Secure WebServer System Administrator’s Guide522659-001
9-31
Context-Management
HttpUtils
This class provides a method to parse a query string or other form-encoded data.
Obtaining Specific CGI Environment Variable Values
To obtain the value of a specific CGI environment variable, use the getAttribute( )
method with the string parameter value
"com.tandem.servlet.parameter-name"
where parameter_name is the name of the desired environment variable.
The following code fragment illustrates the use of getAttribute to obtain and print
an enumeration of environment variables and their values:
out.println("</pre>");
Enumeration x =
(Enumeration)req.getAttribute("com.tandem.servlet.attribute_names");
out.println("<pre>");
while (x.hasMoreElements()) {
String pn = (String)x.nextElement();
out.println(pn +" = " + req.getAttribute(pn) );
}
out.println("</pre>");
Context-Management
Because the same servlet or JSP can be running in multiple processes in the same web
container, a series of requests to the servlet class may not be serviced by the same
process. This situation has important implications for the design of a servlet:
No data maintained by a servlet can be presumed to apply to the servlet class
collectively. Class data applies only within a process.
Context created in memory by one request may not be available to subsequent
requests, because subsequent requests might not execute in the same data space.
Therefore, a servlet that wishes to make context available should write the context to
disk before returning.
Unless you are using session tracking, a feature of the Servlet API, the only way to
ensure that the same process will service a series of requests is to limit the web container
to one process (Maxservers=1). A server class limited in this way retains the quality of
persistence but loses the scalability advantage of a server class. To support sessions, the
web container’s Numstatic and Maxservers attributes must have the same value.
Multithreading - Spawning Java Threads
The NonStop Servlets for JavaServer Pages product supports spawning Java threads
from within a servlet or JSP.
When multiple users access a servlet simultaneously, the web container does not
instantiate a new servlet instance for each user. When a client access the servlet, the
service( ) method is invoked in a separate thread. Therefore each client is sharing the
data of the servlet. In most cases this is by far the most efficient method of handling
multiple requests for servlets that do not contain client data.