I want to get the directory structure inside WebContent folder without resorting to any config file. Is there a way to list folders and pages within the application?
Asked
Active
Viewed 67 times
0
-
See http://stackoverflow.com/a/12160863/3511123 – Jozef Chocholacek Nov 23 '16 at 10:40
-
So I get real path, then enumerate the files from there right? – Teddy Nov 23 '16 at 10:49
-
Exactly, as soon as you have the real path, you can use standard Java filesystem API(s). **Warning**: some servlet containers allow to deploy webapps without expanding the WAR file, i.e. without unpacking it - in such case, `getRealPath()` returns `null`. See http://stackoverflow.com/a/536260/3511123 – Jozef Chocholacek Nov 23 '16 at 10:53
-
Thanks @JozefChocholacek. That's very useful. – Teddy Nov 23 '16 at 10:57