Show TOC Start of Content Area

Background documentation HTTP Response over Persistent Connections  Locate the document in its SAP Library structure

The J2EE Engine’s Web Container attempts to use persistent HTTP connections by default. Persistent connections reuse the TCP/IP connections for several request-response cycles. However, you must observe several considerations in your servlet code, so that persistent connections are used:

·        You must not flush the buffer before the whole response body has been written.

·        If the response body length is larger than the size of the response buffer, or the servlet needs to flush the response stream, the preferred behavior of the servlet is to set the content length of the response. As stated in the JavaÔ Servlet 2.3 Specification, this will achieve the best performance.

·        If you cannot set the content length of the HTTP response body, you can still use persistent connections by configuring the Web Container Service to do Response Chunking (described in the Administration Manual).

Managing the Buffer Size

To use persistent connections, it is important that you set the appropriate size for the buffer to which the output stream writes output. If the buffer becomes full, it is immediately flushed and the response is committed. Therefore, if you send responses with a larger body and you need to maintain persistent connections, you must extend the buffer size above the default value of 4,096 bytes.

To set the buffer size, use the response.setBufferSize(int size) method.

 

 

End of Content Area