public void getPaths() { FacesContext fcontext = FacesContext.getCurrentInstance(); String contextName = fcontext.getExternalContext().getContextName(); ServletContext scontext = (ServletContext) fcontext .getExternalContext().getContext(); String realPath = scontext.getRealPath("/"); System.out.println("RealPath: " + realPath); System.out.println("ContextName: " + contextName); }
The output will be the following:
[STDOUT] RealPath: /usr/local/jboss/jboss-6.0.0.Final/server/default/deploy/MYAPPLICATION.war/
[STDOUT] ContextName: MYAPPLICATION