Bistro!
Alexis Moussine-Pouchkine's Weblog
public enum Topic { Java, GlassFish, Tools, Sun, InFrenchInZeText, SDPY }

20090918 vendredi septembre 18, 2009

GlassFish tip: customize directory listings

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 NAME (default), SIZE, or LAST_MODIFIED.

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 :

  <servlet>
    <servlet-name>default</servlet-name>
    <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
    <init-param>
      <param-name>debug</param-name>
      <param-value>0</param-value>
    </init-param>
    <init-param>
      <param-name>listings</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>sortedBy</param-name>
     <param-value>LAST_MODIFIED</param-value>

    </init-param>  
    <load-on-startup>1</load-on-startup>
  </servlet>

Of course there's also the XSLT approach to have yet more control over the presentation. Check the use of localXsltFile and globalXsltFile in the default-web.xml file itself.

( sept. 18 2009, 04:03:15 AM CEST ) Permalink

Comments:

Post a Comment:

Comments are closed for this entry.

GlassFish Podcast
Get GlassFish V3
Support GlassFish Enterprise

Today's Page Hits: 2972




bea conference glassfish ips java javaee javaee6 javafx javaone javazone jug metro mysql netbeans openesb openoffice opensource paris performance podcast presentation sdpy sun swing techdays tips updatecenter v3 webservices wsit
Links