The first version of ServletExec to support this feature was SE 4.0b1.
There are some conditions which must be met in order to take advantage of this feature:
The request must be made using the HTTP 1.1 protocol.
GET /index.jsp HTTP/1.1
The request must not send the request header named
Connection with the value of
The response must set the response header named
with the appropriate value. This would be done in your servlet code using the
setContentLength() method of the Response object. Otherwise ServletExec has no way of knowing how many bytes a dynamically generated response will be and would therefore have to send a response header named
Connection with a value of
Close thereby telling the client to close the connection.
Note that there is an alternative to the 3rd requirement:
You could use Chunked encoding instead (where each chunk of response data sent to the client has its own sort of content-length information telling how big that response chunk is, and whether or not it is the last chunk). With the Apache webserver, in the absence of the response header named
Content-Length, chunked encoding is used by default for sending responses to the client.
With other webserver (IIS and iPlanet) you would need to manage this in your servlet. The complete steps for writing your servlet code so that it sends a chunked response are beyond the scope of this FAQ, however the general idea for doing this is:
set the HTTP 1.1 response header named
Transfer-Encoding with a value of
When sending the response body (
out.println()), the format of the body must conform to that of a Chunked-body as defined by the HTTP/1.1 Specification.
Readers of this FAQ may also find FAQ #43 to be of interest.
Note: While it is possible to use chunked encoding in either direction (for both requests and responses) ServletExec does not currently support chunked requests. However there may be a workaround