Search code examples
glassfishglassfish-3

Can I configure directory listings and MIME type mappings from command line?


I want to publish a directory of static files alongside my application on GlassFish 3.1; in order to do that, I have to enable directory listings and add a custom MIME type mapping. Since this will only be needed in some installations, I want to do the configuration on the server instead of putting it in the application.

Both can be achieved by editing the default-web.xml file in the domain configuration.

To enable directory listings I have to change the listings parameter to true inside the servlet block:

<servlet>
  <!-- more stuff -->
  <init-param>
    <param-name>listings</param-name>
    <param-value>true</param-value>
  </init-param>
  <!-- more stuff -->
</servlet>

To add a MIME type mapping I have to add a block like this one:

<mime-mapping>
  <extension>ext</extension>
  <mime-type>text/plain</mime-type>
</mime-mapping>

I'd like to do this from a script so that I can reproduce the installation as needed.

Is there a way to change these configurations using asadmin or some other command line tool?


Solution

  • Asadmin does not provide element level access to default-web.xml. That said, you may just want to have an alternate copy of default-web.xml and then use a script to replace the 'shipped' version with the customized version.