Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it possible to list files under certain folder with servlet

 
Tapio Niemela
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64847
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic