Using java.io.File I want to retreive (FileRetriever.java) the specific files, from JBoss Server deployment folder. For example, following are the paths of deployed project. Using FileRetriever.java I want to get the fles from the directory ..\layout\templates\.
Please suggest how can I do this dynamically i.e the FileRetriever.java should get the folder path (\layout\templates) depending on its (FileRetriever.java or FileRetriever.class) location. It needs to be irrespective of location of JBoss Server Installation. Is there any altenative using web.xml or component.xml files.
String serverPath= getServletContext().getRealPath("/");
This will give you full path of the server from root directory to your web application directory.
For me its: " D:\local\tomcat-6.0.29\webapps\myapp " when I sys out from myapp application.
Once you got the whole real path for the server system as above you can get the path relative to your directory.
So if I have some data file in myapp\data - I can get it appending \data\filename to the serverPath which we got earlier.
This will work in all situation even you have multiple servers installed on the same system.
Hope this will work for you.