FacesContext context = FacesContext.getCurrentInstance();
if (context == null) {
if (log.isTraceEnabled()) {
log.trace(" Creating new FacesContext for '" + uri + "'");
}
FacesContextFactory fcf = (FacesContextFactory)
FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request, uri);
context = fcf.getFacesContext(servlet.getServletContext(), wrapper,
response, lifecycle);
// Comment out the previous two lines and uncomment
// the following line to test eliminating the wrapper
context = fcf.getFacesContext(servlet.getServletContext(),
request, response, lifecycle);
}
// Create a new view root
ViewHandler vh = context.getApplication().getViewHandler();