FacesContext facesContext = FacesContext.getCurrentInstance();
if (!WebConfigParamUtils.getBooleanInitParameter(facesContext.getExternalContext(), INITIALIZE_ALWAYS_STANDALONE, false))
{
//We need to check if the current application was initialized by myfaces
WebConfigProvider webConfigProvider = WebConfigProviderFactory.getWebConfigProviderFactory(
facesContext.getExternalContext()).getWebConfigProvider(facesContext.getExternalContext());
if (webConfigProvider.getFacesServletMappings(facesContext.getExternalContext()).isEmpty()) {
// check if the FacesServlet has been added dynamically
// in a Servlet 3.0 environment by MyFacesContainerInitializer
Boolean mappingAdded = (Boolean) servletContext.getAttribute(FACES_SERVLET_ADDED_ATTRIBUTE);
if (mappingAdded == null || !mappingAdded)
{