New sorting options for directory listings in GlassFish v3

New sorting options for directory listings in GlassFish v3

New sorting options for directory listings in GlassFish v3

The section in the Servlet specification that talks about Welcome Files has this:

If no matching welcome file is found in the manner described, the container may handle the request in a manner it finds suitable. For some configurations this may mean returning a directory listing or for others returning a 404 response.

GlassFish may be configured to return a directory listing if a request fails to be mapped to any welcome page, by setting the listings init parameter in the DefaultServlet declaration of the domain's default-web.xml to true, as follows:

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

Up until now, the directory listings were always sorted in alphabetical order.

The latest GlassFish v3 provides additional sorting options by last-modified date and size, by introducing a new init parameter with name sortedBy for the DefaultServlet, whose value may be set to one of NAME (the default), LAST_MODIFIED, or SIZE, as follows:

  <servlet>
    <servlet-name>default</servlet-name>
    <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
    <init-param>
      <param-name>listings</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>sortedBy</param-name>
      <param-value>[NAME|LAST_MODIFIED|SIZE]</param-value>
    </init-param>
  </servlet>

Please send any questions or comments you may have to the GlassFish webtier alias, or post them to the GlassFish webtier forum.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

jluehe

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today