Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > getting the disk absolute path of a web-app

Reply
Thread Tools

getting the disk absolute path of a web-app

 
 
yair
Guest
Posts: n/a
 
      11-04-2004
hey all
in a servlet running in tomcat, how can i get the full path of my web
application on the disk (something like "c:\progran
files\tomcat\webapps\myApp")?
i don't want to write it in the web.xml or to pass it as a system
property.
thanks
yair
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      11-04-2004
On 4 Nov 2004 02:35:57 -0800, yair wrote:

> how can i get the full path of my web
> application on the disk (something like "c:\progran
> files\tomcat\webapps\myApp")?


javax.servlet.ServletContext.getRealPath(java.lang .String)

HTH

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
 
Reply With Quote
 
 
 
 
Will Hartung
Guest
Posts: n/a
 
      11-04-2004
"Andrew Thompson" <(E-Mail Removed)> wrote in message
news:1r726yuynwivh$(E-Mail Removed)...
> On 4 Nov 2004 02:35:57 -0800, yair wrote:
>
> > how can i get the full path of my web
> > application on the disk (something like "c:\progran
> > files\tomcat\webapps\myApp")?

>
> javax.servlet.ServletContext.getRealPath(java.lang .String)


However, this is not guaranteed to not return null. If, for example, your
web-app is running from an unexploded WAR file, you won't get a useable
value.

Regards,

Will Hartung
((E-Mail Removed))



 
Reply With Quote
 
Juha Laiho
Guest
Posts: n/a
 
      11-06-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (yair) said:
>in a servlet running in tomcat, how can i get the full path of my web
>application on the disk (something like "c:\progran
>files\tomcat\webapps\myApp")?
>i don't want to write it in the web.xml or to pass it as a system
>property.


Adding to the response by Will Hartung; for what would you need this;
what would you do with the information? Once we know that, we may be
able to propose alternative ways of solving the problem.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
 
Reply With Quote
 
yair
Guest
Posts: n/a
 
      11-07-2004
Juha Laiho <(E-Mail Removed)> wrote in message news:<cmjbqi$2r2$(E-Mail Removed)-int>...
> (E-Mail Removed) (yair) said:
> >in a servlet running in tomcat, how can i get the full path of my web
> >application on the disk (something like "c:\progran
> >files\tomcat\webapps\myApp")?
> >i don't want to write it in the web.xml or to pass it as a system
> >property.

>
> Adding to the response by Will Hartung; for what would you need this;
> what would you do with the information? Once we know that, we may be
> able to propose alternative ways of solving the problem.


thanks for u're answer first.

i will have a folder named "tests" under webapps/myApp, and i want to
read the names of the files in this folder. i m going to show the user
a page with the names of those files and let him choose a file to run
(this ofcourse is a very simplified version of what i m trying to do).
this webapp will not be JAR-ed, so i dont have a problem with that.

it seems like:
javax.servlet.ServletContext.getRealPath("")
or
javax.servlet.ServletContext.getRealPath("/")
r working fine, i think i'll use this way.
thanks
yair
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does one get an absolute absolute file path? James Byrne Ruby 3 09-14-2010 06:02 PM
How do I convert an absolute path into a relative path Nigel Wilkinson Ruby 2 07-25-2005 07:37 PM
Absolute path in Manifest Class-Path header? bo_kid@yahoo.com Java 10 05-30-2005 01:43 PM
absolute path versus relative path in JSP Matt Java 3 07-08-2004 08:31 PM
Make a relative url path from an absolute path to another one Thomas Guettler Python 3 10-27-2003 04:41 PM



Advertisments