users@javaserverfaces-spec-public.java.net

[jsr344-experts mirror] [jsr344-experts] 1012 ExternalContext.getApplicationContextPath()

From: Neil Griffin <neil.griffin_at_portletfaces.org>
Date: Tue, 18 Dec 2012 14:48:23 -0500

Hi Ed,

Regarding issue 1012 [1], the JSF 2.2 JavaDocs expose a new method on ExternalContext named getApplicationContextPath() which has the following requirements:

     * <p class="changed_added_2_2"><em>Servlet:</em>
     * Return the result of calling
     * <code>getContextPath()</code> on the
     * <code>ServletContext</code> instance for this application. It is
     * valid to call this method during application startup or shutdown.</p>

Since FacesContext.getCurrentInstance() is a ThreadLocal singleton bound to the request thread, it is not possible to call FacesContext.getCurrentInstance().getExternalContext() during application startup or shutdown.

Also, the Portlet API does not provide access to the underlying ServletContext. I suppose that the best we could do in a portlet environment would be to register a ServletContextListener and remember the ServletContext instance for later reference.

When you get a chance, could you elaborate on what made it necessary to add the getApplicationContextPath() feature?

Thanks,

Neil

[1] http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1012