jeudi sept. 17, 2009

GlassFish tip: customize directory listings

This blog has moved to alexismp.wordpress.com
Follow the link for the most up-to-date version of this blog entry.

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.

jeudi févr. 15, 2007

How to use Tomcat Context information in GlassFish


If you're using Tomcat and you are looking into moving to GlassFish (because of Java EE 5, admin tools, Grizzly performance, etc...), you might find this question I was asked twice recently about a specific feature migration.

If you were using Tomcat's Context feature and reading the initialization parameters say from servletContext.getInitParameter(), you need to provide the same information in a slightly different format in the standard web.xml deployment descriptor.

<context-param>
   <param-name>param</param-name>
   <param-value>value</param-value>
</context-param>

Note this can also be added to $GLASSFISH_HOME/domains/$DOMAIN_NAME/config/default-web.xml if you don't want to repeat this in all your web-apps. But be careful as it takes precedence over the web application web.xml.



vendredi févr. 02, 2007

Flexible GlassFish domain creation using --portbase

This blog has moved to alexismp.wordpress.com
Follow the link for the most up-to-date version of this blog entry.


Marseille PortOne nice thing about GlassFish is the notion of a domain. A single installation can have multiple domains, each being created with the asadmin create-domain command. I use that a lot to separate clients and servers when using web services for instance. If you're not using Solaris Containers/Zones which have their own set of ports, you have to have different port settings for each domain. Default ports for GlassFish are as follows:
    4848 for Admin
    8080 
for HTTP Instance
    7676 
for JMS
    3700 
for IIOP
    8181 
for HTTP_SSL
    3820 
for IIOP_SSL
    3920 
for IIOP_MUTUALAUTH
    8686 
for JMX_ADMIN
When creating a new domain, I usually always start the other domains I'd like to see running at the same time and specify new Admin and HTTP Instance ports. The reason for starting first other domains is to make sure the new domain with not be created with any ports already in use (exact ports used are shown during domain creation).

The other option I recently found out about is --portbase. This allows you to provide a base port and have other ports defined as offsets.
Taken straight from the asadmin create-domain --help output:
 --portbase
       Determines the number with which the  port  assignment
       should  start. A domain uses a certain number of ports
       that are  statically  assigned.   The  portbase  value
       determines  where  the assignment should start. Choose
       this value judiciously. The values for the  ports  are
       calculated as follows: Admin port: portbase + 48, HTTP
       listener port: portbase  +  80,  IIOP  listener  port:
       portbase + 37, JMX port: portbase + 86. See the output
       of this command for a complete list of occupied ports,
       when --portbase option is specified.

      Note:

      The --portbase  option  cannot  be  used  with  the  --
      adminport or the --instanceport option.


Also note that when it comes to ports, GlassFish now also has this optionnal feature of unifying ports as described here.

About

This blog has moved

Alexis Moussine-Pouchkine's Weblog

GlassFish - Stay Connected

Search

Archives
« avril 2014
lun.mar.mer.jeu.ven.sam.dim.
 
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
Blogroll

No bookmarks in folder

News

No bookmarks in folder