• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Is it possible to list files under certain folder with servlet

 
Ranch Hand
Posts: 91
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic