// Create dummy UIViewRoot
UIViewRoot root = new UIViewRoot();
root.setRenderKitId("dummy");
// Setup the FacesStreamerContext
Context fsContext = new FacesStreamerContext(context);
fsContext.setAttribute(Context.FILE_PATH, path);
// Get the HttpServletResponse
Object obj = context.getExternalContext().getResponse();
HttpServletResponse resp = null;
if (obj instanceof HttpServletResponse) {
resp = (HttpServletResponse) obj;
// We have an HttpServlet response, do some extra stuff...
// Check the last modified time to see if we need to serve the resource
long mod = fsContext.getContentSource().getLastModified(fsContext);
if (mod != -1) {
long ifModifiedSince = ((HttpServletRequest)
context.getExternalContext().getRequest()).
getDateHeader("If-Modified-Since");
// Round down to the nearest second for a proper compare