• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Absolute path of a webapp

 
Fernando Dominguez
Ranch Hand
Posts: 106
Debian Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Is there any way to Know the absolute path of the system where the servlet is runnig?

For example /usr/local/tomcat/webapps/aplication/

I need it beacause I have to read some conf files under /aplication/conf/



[BPS: changed subject to more closely match the question]
[ September 01, 2006: Message edited by: Ben Souther ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked in the ServletContext API?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, no, and maybe.
All of the above apply.

Java EE (formerly j2ee) webapps can be deployed as a working file system but they don't have to be. They can also be run as packed war files. Also, parts of a webapp can be bundled into jar files.

If your app has been deployed as an exploded file system, ServletContext.getRealPath("/") will return the path to the root of the web application. If not, then there really isn't a filesystem to access. In this case getRealPath will return null.

As Bear mentioned, the best place to find this information is either the API or the Servlet Spec (links to both are in my signature.).

Good-Luck
-Ben
[ September 01, 2006: Message edited by: Ben Souther ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic