Show TOC Start of Content Area

Function documentation Providing Long-lived Request and Response Objects  Locate the document in its SAP Library structure

Use

The J2EE Engine provides a Web-based solution that enables client request and response objects to be used and the virtual client connection to be available after releasing the client thread. This solution is implemented in the ConnectionWrapperfilter.

The ConnectionWrapperfilter solution has been designed to facilitate specific Web application scenarios.

One Sharer and Multiple Viewers Scenario

This graphic is explained in the accompanying text

The purpose of the sharer component is to send periodically notifications, or other data, to multiple viewer components that are registered with it. The viewer components access the sharer component once, which is necessary to “register” themselves with it. After the first access, their response streams are not closed; the sharer component uses the streams to send the data periodically.

Features

The J2EE Engine’s Web Container implementation maintains a pool of request and response objects. It initializes objects from that pool with the client parameters and passes them to the servlet instance that must process the client request. After the response has been committed, those objects are returned back to the pool. What the ConnectionWrapper filter does is to create new request and response objects by copying the parameters from the original ones, and to pass them to the corresponding servlet. The original objects are returned to the pool. The request and response objects created by the ConnectionWrapper are not finalized after the thread completes executing in the service method of the servlet, nor the response stream is automatically closed. Therefore, they can be used by the sharer to send data periodically to the viewers.

The resources must be released when the client connection is closed. If such an event occurs, the servlet gets notion of it by the exception that is thrown when it tries to read or write from the client’s input and output streams. For more information about this exception, see IOException in Cases When Client Closes Connection.

There is an alternative way to get notion of the event of closed client connection. It is possible to implement a listener. It must implement the java.util.EventListener interface and declare the following method:

public void connectionClosed(ServletRequest request, ServletResponse response)

The above method is called when the client connection is closed.

The listener class must be declared in the standard web.xml descriptor of the Web application.

Activities

The ConnectionWrapperfilter is distributed as part of the J2EE Engine’s Web Container. It is declared in the global-web.xml, which makes it available to all Web applications deployed on the Web Container. To enable it for your Web application, you must map it to a URL pattern or a particular servlet.

End of Content Area