Home


Skip-cache-attribute

This defines an attribute that, when present in a request, specifies that the response cannot be retrieved from or stored in the specific cache instance. The following three examples illustrate the use of this attribute.

Example | -3 applies to the base cache; Example | -4 applies to cacheinstance1. To invoke the skip-cache functionality, simply set the request attribute previewRequest to true as shown in Example | -5. SkipCache.jsp is then not retrieved from cache regardless of its cache policy.

Example 6-3 cachespec.xml (Base Cache)

<cache>
    <skip-cache-attribute>previewRequest</skip-cache-attribute>
.
.
.
</cache>

Example 6-4 cachespec.xml (cacheinstance1)

<cache-instance name="cacheinstance1">
    <skip-cache-attribute>previewRequest</skip-cache-attribute>
.
.
.
</cache-instance>

Example 6-5 Invoking skip-cache from a filter

public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain)    {       
    try        {          
        String parm = request.getParameter("previewRequest");          
        if (parm == null)   
            request.setAttribute("previewRequest",null);    
        else if (parm.equals("true"))
            request.setAttribute("previewRequest","true"); 
        else if (parm.equals("false"))        
            request.setAttribute("previewRequest","false");        
        
        chain.doFilter(request, response);        
    }
    catch (Throwable t) {}}

+

Search Tips   |   Advanced Search