GlassFish tip: customize directory listings
September 17, 2009 Comments Off
With GlassFish being a very capable HTTP server out of the bowser (thank you Grizzly!), it was time for v3 to offer the ability to configure directory listings. It is now possible to have pages listing files per
Configuration can be done inside
web.xml (in the form of an additional
init-param to the
DefaultServlet servlet called
sortedBy). This would hold true for a given application and support dynamic reloading (no full redeploy, no restart to take changes into account).
You might find it more convenient to have it be part of
default-web.xml (located in
domains/domain1/config/). Of course that would require restarting the container. In both cases, the listing should be explicitly allowed or else the user will see a 404 Not Found error. Here’s an example to configure the listing presentation in either config files :
Of course there’s also the XSLT approach to have yet more control over the presentation. Check the use of
globalXsltFile in the
default-web.xml file itself.