I need to list files under a folder of a different web application. Is there a way to get this done without having to provide the actual path in a properties file?
Webapps
- WebApp1
-MyFolderOfInterest
- WebApp2
- WEB-INF
- Classes
- MyClasstoListFiles
TIA
Yes, in a servlet of yours:
The important things here is that you gain access to a
ServletContextdifferent than the one you are currently in. See the documentation ofgetContext()And in order to make a context eligible for access from other contexts, for WebApp2 you need a
context.xml(inMETA-INF, for example) that contains: