This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes path of application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "path of application" Watch "path of application" New topic
Author

path of application

raj baig
Ranch Hand

Joined: Jul 11, 2006
Posts: 96
hi all,

can you tell me how to get my complete path of web application.

like: c:\prog files\tomcat\webapp\myapp

how can i get this path in my servlet

thank you all.
Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
In your JSP, you can use application.getRealPath("/"). In your servlet, use the ServletContext.getRealPath("/").

One thing to note is that not all containers deploy your application by exploding them into certain directory. Some is using the WAR/EAR file as a whole.


SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
raj baig
Ranch Hand

Joined: Jul 11, 2006
Posts: 96
in case of war file can you tell me how to achieve the path
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Depends what you want to do. If you want to write/edit files, it is not so easy. If you are looking to read from a file, you can (usually) use the ClassLoader to find an InputStream from files in the WAR/EAR
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: path of application