aspose file tools*
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
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
 
Similar Threads
File reading from any path
Directory creation in the server
migrate program from unix to windows, confuse about Path
Get absolute path using Java
How can I get application path from java code?