Pretty much any language is capable of scanning a directory. Reading on a client cannot be done without a client language, and reading from a server takes a server language. I'd bet that JS itself could not read the filesystem of the client. Java itself can have an app written to perform this task. If its already on the server, then your processing language there would scan and show as necessary.
Web processing languages job is to dynamically generate content from either changing information or from user input. So sure you can set this up to do what you want. But you do need to choose the language you are planning to use first; JSP requires a JSP compatible server, ASP.NET would require IIS, PHP is pretty much fair game anywhere as is Perl. All of these languages can iterate a directory and choose files if you provide it something to compare against so long as they are on the server itself.