By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,826 Members | 815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,826 IT Pros & Developers. It's quick & easy.

where can I find my servlet ? :)

P: n/a
I have Tomcat running a servlet that needs to know the location of the
WebApp that contains it (actually it needs to know the full path to
itself). I thought that the servlet path was relative to the Tomcat
bin directory (since tomcat si actually running this service). I did a
simple test and found out that tomcat is actually running from
c:\WINDOWS\system32 ... so that's the path that the servlet is
relative to.

Now, normally, that wouldn't bother me much but I really need to know
the path to my servlet (in some sort of multi-platfrom way - since
this revlet is going to be run on a linux server - that dosen't have
any C:\WINDOWS\system32 :D ).
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Silviu-Lucian" <lu****@nortex.ro> wrote in message
news:78**************************@posting.google.c om...
I have Tomcat running a servlet that needs to know the location of the
WebApp that contains it (actually it needs to know the full path to
itself). I thought that the servlet path was relative to the Tomcat
bin directory (since tomcat si actually running this service). I did a
simple test and found out that tomcat is actually running from
c:\WINDOWS\system32 ... so that's the path that the servlet is
relative to.

Now, normally, that wouldn't bother me much but I really need to know
the path to my servlet (in some sort of multi-platfrom way - since
this revlet is going to be run on a linux server - that dosen't have
any C:\WINDOWS\system32 :D ).


I assume since you're using a servlet you'll have access to the
ServletContext. I think you'll find something useful in these methods:

getRealPath()
getResourceAsStream()
getResourcePaths()

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.