The following document illustrates how to get started writing a web application using common code that we have been using or developing over the last few years. We also describe how to deploy the application to a web server.

Web Application Skeleton

To download the skeleton of the web application do a cvs export of the module org-glast-web-base-application (CVSROOT is :ext:USERNAME@glast-java.slac.stanford.edu:/cvs/java where USERNAME is you). If you are using Tortoise CVS you have to select "CVS checkout .." and unser "Options" select "Export".

You should now be able to open this maven1 project in Netbeans and deploy it to the bundled Tomcat Server.

GLAST Commons

The GLAST Commons is a collections of common code that can and should be shared across different GLAST web application providing a uniform look and feel. The following items are provided by the GLAST Commons and are used in the skeleton provided above:

Filters

The GLAST Commons provide three filters that are by default included in the above skeleton application:

To disable any of these filters you'll have to remove their specification in src/webapp/WEB-INF/web.xml.

Sitemesh

Sitemesh is used to decorate the pages, making sure they all get a similar look and feel. Please refer to the sitemesh documentation for more information.

The main sitemesh related files are the following:

The above decorators share common code stored in the form of tag files:

Finally for sitemesh to work a filter needs to be added to the application. It's the filter that is responsible for mangling your jsp code with the decorating templates. This is done in src/webapp/WEB-INF/web.xml with the following code:

    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

If you are not interested in sitemesh you can remove the filter definition in web.xml and all the above files.

Display Tag For Tables

We use the Display tag library to create sortable tables. We provide a simple jsp example (src/webapp/table.jsp) that displays a sample list of items created using the java classes in src/main/java/org/glast/web/base/table.

To use the Display tag library all you have to do is to include the tag library definition at the top of your jsp page:

      <%@taglib prefix="display" uri="http://displaytag.sf.net" %>

and use the prefix display to access the table tags.

Additionally, if you specify the table's class to be datatable, as done in the example below, you will get the default styles provided by the GLAST Commons and used by most of the other GLAST web applications.

        <display:table  class="datatable" name="${table}"  defaultorder="ascending"  sort="list" id="tableId" >

Relevant to Display Tag is the properties file src/webapp/WEB-INF/classes/displaytag.properties which allows some configuration; please refer to the Display tag configuration documentation for a list of all the available properties.

AIDATLD For Plots

We create our plots using the AIDATLD jsp tags. The jsp file src/webapp/aidaPlot.jsp shows a sample plot extracted from the AIDATLD examples.

FreeHEP WebUtil

The FreeHEP WebUtil library provides some additional common code to be used in web application:

Related to the FreeHEP WebUtil code is the properties file src/webapp/WEB-INF/classes/freehepWebapp.properties that allows to configure the above items. Please refer to the FreeHEP WebUtil documentation for a list of the available parameters.

Logging

By default logging is turned on, using java.util.logging. The logging parameters are controlled via the properties file src/webapp/WEB-INF/classes/logging.properties. For additional information on logging in Tomcat, please refer to the following documentation.