Receives notification that the request is about to enter the scope
of the web application, and adds newly created cache for JSP tag
body invocations as a request attribute.
ServletContext context = sre.getServletContext();
// Check if a cache manager has already been created and set in the
// context
CacheManager cm = (CacheManager)
context.getAttribute(CacheManager.CACHE_MANAGER_ATTR_NAME);
// Create a new cache manager if one is not present and use it
// to create a new cache
if (cm == null) {
cm = new CacheManager();
}
Cache cache = null;
try {
cache = cm.createCache();
} catch (Exception ex) {}
// Set the cache as a request attribute
if (cache != null) {
ServletRequest req = sre.getServletRequest();
req.setAttribute(Constants.JSPTAG_CACHE_KEY, cache);
}