Get project path

0

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?

    
asked by anonymous 03.01.2018 / 15:20

1 answer

0

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.

    
03.01.2018 / 15:50