I have a JSF
project and would like to return the project path in String
. This path must take the webapp
folder to be root. How do I do it?
I have a JSF
project and would like to return the project path in String
. This path must take the webapp
folder to be root. How do I do it?
To get the project path, use:
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
String diretorio = ec.getRealPath("/");
This "directory" string will leave you at the root of your project. With this, you simply manipulate the string to go to the directory you want.
A replace
, for example, would do exactly what you wanted.