NonStop Servlets for JSP System Administrator's Guide
Programming and Management Features
NonStop Servlets for JavaServer Pages (NSJSP) System Administrator’s Guide—525644-001
4-5
Obtaining Specific CGI Environment Variable Values
The HttpServletRequest Class
This class extends the ServletRequest class, which provides methods for retrieving
information from a standard input stream and obtaining the values of various headers
and environment variables. The HttpServletRequest class defines methods for
obtaining HTTP-protocol header information and CGI environment variables such as
QUERY_STRING, PATH_INFO, and PATH_TRANSLATED.
To obtain an enumeration of all CGI environment variables in effect for a servlet, use
the getAttribute() method with the string parameter value
"com.tandem.servlet.attribute_names"
The HttpServletResponse Class
This class extends the ServletResponse class, which provides methods for writing
to the standard output stream and error file. The HttpServletResponse class
defines methods for sending HTTP response headers and error information to the web
client.
To generate its own response headers, a servlet must generate all such headers
before writing any data to the output stream; otherwise, the ServletOutputStream
class sends only the following header:
CONTENT_TYPE=text/html
The ServletException Class
This class provides methods for reporting servlet-specific exceptions. The doGet()
and doPost() methods of your servlet should use this class, or a class you derive
from this class, to report an error.
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 code fragment in Example 4-1 illustrates the use of getAttribute to obtain and
print an enumeration of environment variables and their values: