String resourceUri) throws IOException {
// get the FacesContext from the ServletContext.
FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifecycleFactory.getLifecycle(HtmlComponentUtils
.getLifecycleId(servletContext));
FacesContext facesContext = facesContextFactory.getFacesContext(
servletContext, request, response, lifecycle);
facesContext.setResponseStream(new CAPTCHAResponseStream(response
.getOutputStream()));