Use this task to configure the DynamicContentProvider interface for cached servlets and JavaServer Pages files. The dynamic cache service should be enabled and you should be using servlet caching. See Enabling the dynamic cache service and Configuring servlet caching for more information.
Servlets or JSP files that implement the DynamicContentProvider interface can add user exits in fragments that are cacheable by calling the addDynamicContentProvider(DCP) method on the wrapper response object. When the dynamic cache renders the page, it identifies the user exit and calls the dynamic content provider to add the dynamic content to the rendered page.
class DynamicContentProviderImpl implements com.ibm.websphere.servlet.cache. DynamicContentProvider { DynamicContentProviderImpl() {} public void provideDynamicContent(HttpServletRequest request, OutputStream streamWriter) throws IOException { String dynamicContent = System.currentTimeMillis(); streamWriter.write(dynamicContent.getBytes()); } public void provideDynamicContent(HttpServletRequest request, Writer streamWriter) throws IOException { String dynamicContent = System.currentTimeMillis(); streamWriter.write(dynamicContent.toCharArray()); } }
public class DCPServlet extends CacheTestCase { public void performTest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { out.println(“Testing the DCP feature begin ”+System.currentTimeMillis()); DynamicContentProvider dcp = new DynamicContentProviderImpl(); ServletCacheResponse scr = (ServletCacheResponse)(response); scr.addDynamicContentProvider(dcp); out.println("Testing the DCP feature end”+System.currentTimeMillis()); } }