Is it possible to list files under certain folder with servlet
posted 7 years ago
Is it possible to list folders under certain folder under /WEB-INF using servlet? I'm trying to read multiple config.xmls into application. E.g. the idea is that when *.xml is located in /WEB-INF/config-folder it will be read and information will be stored in application for future use.
There's method called getResourceAsStream(String) with ServletContext, but this can't return folder (e.g. files beneath it; I have to know excat name of the file to be able to read it, but I don't actually know the excat names of the *.xml-files, just that they reside in config-folder), there's also method called getRealPath(), but it doesn't seem to be correct either, it has problems with war-files for example. Can someone help me, please?
There's not going to be a single solution. If the app is not running out of a war file, you can use getRalPath() and the java.io classes. If the app is running out of a war, I imagine you'll need to use the ZIP file classes.