Application app = getApplicationUnchecked();
// We initialize a temporary context
ExternalContext extCtx = facesContext.getExternalContext();
final XspContext newContext = ctx = (XspContext)initContext(app, extCtx.getRequest(), extCtx.getResponse());
// we should clear the context when the JSF context is discarded
facesContext.addRequestListener(new FacesContextListener() {
public void beforeRenderingPhase(FacesContext facesContext) {
}
public void beforeContextReleased(FacesContext facesContext) {
destroyContext(newContext);
}