• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving Server Path Programmatically

 
James Gordon
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using Tomcat as my web server.
My project is in c:\tomcat\webapps\myproject
Is there a way to retrieve the project path (which is the path above) from either the servlet or bean?
I tried using ServletContext.getRealPath(Str) but I need to provide a String a location in returns.
I had even tried System.getProperty("user.dir") but it gives me the c:\tomcat\bin

Thanks in advance.
 
prabhat kumar
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is simple ..
use
getServletContext().getRealPath("/") ;
 
James Gordon
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Tried the above suggestion and what I get is this:
C:\tomcat\bin\..\webapps\MyProject\
Not sure why I got the "bin\..\" part.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic