Search code examples
tomcatweb.xmltomcat8

Directory Listings Sort Order in Tomcat 8


I enabled directory listings for my web-app by using in my web.xml

<init-param>
    <param-name>listings</param-name>
    <param-value>true</param-value>
</init-param>

This works. However the sort order seems arbitratry. In a folder with files only, they are neither sorted by name, size, nor modification date.

Is there a way to controll the sort order?


Solution

  • I added this to Tomcat Bugzilla, https://issues.apache.org/bugzilla/show_bug.cgi?id=57287

    As a workaround: The DefaultServlet can generate the listing as XML and can apply XSLT transformation to it. Sorting can be done within XSLT.

    (Generating XML listing and applying XSTL is documented in Tomcat Documentation > Default Servlet > How do I customize directory listings?)