• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application root

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there!
How can I figure out programmatically the application root?
I have the page
http://localhost/test
located at
c:\tomcat\webapps\test
Now can I programmatically get c:\tomcat\webapps\test out from http://localhost/test (or preferrably plain test)?
The example is tomcat, but I would like to see a solution where it does not matter whether container is WebLogic, Jetty or sum else...
Thx in advance!
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was easy:
getServletConfig().getServletContext().getRealPath("/")
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Antti Barck:
This was easy:
getServletConfig().getServletContext().getRealPath("/")

It seems that this approach fails when app is in .war?!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic