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

Using NonStop Servlets for JavaServer Pages
(NSJSP)
iTP Secure WebServer System Administrator’s Guide523346-002
9-29
Client Programming Considerations
Client Programming Considerations
This subsection describes how to refer to a servlet in an HTML document and how to
send requests to and receive responses from a servlet. To an HTML document or a
web client, there is very little difference between using a servlet and using any other
type of CGI application.
Before you read this, you should be familiar with the information in Section 8, Using
Common Gateway Interface (CGI) Programs.
Invoking a Servlet
You invoke a servlet by including a reference to its URL. The syntax of a servlet URL is
described in Map Requests to Applications and Servlets on page 9-28.
Passing Request Information
You can pass request information to a servlet by any of the following means:
Query strings appended to URLs. The servlet receives this data through the
QUERY_STRING environment variable, or through a hash table if the servlet uses
the HttpUtils class.
Extra path information appended to URLs. The servlet receives this information
through the PATH_INFO and PATH_TRANSLATED environment variables.
HTML forms. A servlet receives data from HTML forms in an input stream.
A servlet accesses environment variables and the input stream through an object, as
described in Using the Servlet API on page 9-31.
Receiving Response Information
The response from a servlet has the same form as the output from any other CGI
program. That is, the response consists of:
One or more http response headers
A blank line
The response content
However, the servlet itself need not generate all these elements. If the servlet does
not provide header information, the servlet methods insert the header
content-type: text/html. If the servlet does not include the blank line, the servlet
methods insert the required carriage return and linefeed.
For information about how a servlet generates its output, see Using the Servlet API on
page 9-31.