0

I'm working on a JSF application and I want to launch a script located in my Web projet, how can I make this without beginning the path from c:....., is there a way to get the root path of a JSF application?

Potinos
  • 371
  • 3
  • 5
  • 15
  • 1
    What do you want to achieve - lookup a resource file? And from where? Javascript? Serverside? – Zeemee Jul 17 '12 at 14:32

2 Answers2

1

If you mean a script that is running in your webpage, then / is the root of your application.

Zeemee
  • 10,486
  • 14
  • 51
  • 81
  • 2
    OK Thank you, I have found it : FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath() – Potinos Jul 17 '12 at 14:36
0
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); 

String webContentRoot = ec.getRealPath("/")

As shown above, first initialise the ExternalContext object. Then call the object's getRealPath("/") method to get the root path of your application.

Charles
  • 320
  • 2
  • 8
  • Not sure what was the question, but this answer helped me developing with Eclipse where I could get a real path of the folder Eclipse and Tomcat put my project to. It was _C:\Program Files\apache-tomcat-8.0.35\wtpwebapps\MyProjcet_. – Mladen Jun 16 '16 at 20:48