On 7/28/06, Marty Phee <[EMAIL PROTECTED]> wrote:
How do I get the application path.
I can see it in the debugger through the ApplicationContextFacade, but
not sure how to access it.
I need the path of the application to pass on to a report generator.
(Quoting my answer from the Struts User list version of this question)
By "application path" do you mean the directory path to where the
application is deployed from on disk? You are correct in noticing that this
is not exposed to the application via JSF APIs ... in part because there
might not actually be such a thing (for example, if the app server runs your
application from an unpacked WAR fie, or puts all the resources into a
database or somethng like thiat). The best you can do is infer it from a
call like this:
FacesContext fcontext = FacesContext.getCurrentInstance();
ServletContext scontext = (ServletContext) fcontext.getExternalContext
().getContext();
String path = scontext.getRealPath("/index.html"); // Or some resource
known to exist
... check path for being null ...
... strinp off the last segment to get the directory path ...
Craig
thanks,
Marty