public static UIViewRoot findRoot(FacesContext context, ServletRequest req, Object etag) throws Exception { if (context == null) context = FacesContext.getCurrentInstance(); UIViewRoot root = context.getViewRoot(); if (root == null) throw new NullPointerException(L.l("f:view can't find current in FacesContext")); Object oldETag = root.getAttributes().get("caucho.etag"); if (oldETag != null && !oldETag.equals(etag)) { // clear view on JSP change root.getChildren().clear(); root.getFacets().clear(); } root.getAttributes().put("caucho.etag", etag); return root; }