NonStop Servlets for JavaServer Pages (NSJSP) 6.0 System Administrator's Guide
Programming and Management Features
NonStop Servlets for JavaServer Pages (NSJSP) 6.0 System Administrator’s Guide—544548-004
4-6
Obtaining Specific CGI Environment Variable Values
Obtaining Specific CGI Environment Variable Values
To obtain the value of a specific CGI environment variable, use the
getHeaderNames() or getAttribute() methods with the string parameter value
"com.tandem.servlet.parameter-name"
where:
parameter-name
is the name of the desired environment variable.
The code fragment in Example 4-1 illustrates the use of getAttribute to obtain and
print an enumeration of environment variables and their values:
Context Management
A series of requests to the servlet class may not be serviced by the same process
because the same servlet or JSP might be running in multiple processes. This situation
has 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 run in the same data space.
Therefore, a servlet that needs to make context available must write the context to
the disk before returning.
Unless you are using session tracking, a feature of the Servlet API, the only way to
ensure that the same process services a series of requests is to limit the web container
to one process (Maxservers=1). A ServerClass limited in this manner retains the
quality of persistence but loses the scalability advantage of a ServerClass. To support
sessions, the Numstatic and Maxservers attributes in the web container must have
the same values unless you are using persistent sessions and stopping session-based
load balancing. For information on stopping session-based load balancing, see Java
Runtime Arguments on page 3-3.
Example 4-1. Using the getAttribute() method to obtain Environment Variables
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>");










