aspose file tools*
The moose likes Servlets and the fly likes Is it possible to list files under certain folder with servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Is it possible to list files under certain folder with servlet" Watch "Is it possible to list files under certain folder with servlet" New topic
Author

Is it possible to list files under certain folder with servlet

Tapio Niemela
Ranch Hand

Joined: Jan 06, 2006
Posts: 77
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?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible to list files under certain folder with servlet