Forums Register Login

Retrieving Server Path Programmatically

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
it is simple ..
use
getServletContext().getRealPath("/") ;
+Pie Number of slices to send: Send
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.
Your mind is under my control .... your will is now mine .... read this tiny ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 558 times.
Similar Threads
getting file from VSS
Eclipse: How to add Tomcat Library?
start tomcat dynamically
Please Help----very urgent
start tomcat dynamically
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:01:30.