Qwicap Deployment Descriptors

Chris W. Johnson
Information Technology Services
The University of Texas at Austin
March 30, 2011

Contents

Quick Start

If all you need is a "web.xml" file that will make your Qwicap web application work, skip down to the default file shown below, and use it. No modifications should be required. If you want an understanding of the web application deployment descriptor, or Qwicap's automatic entry point detection feature, read on.

Introduction

Qwicap is based on Java Servlets, and provides a servlet class that manages all Qwicap-based web applications. Those applications are not, themselves, servlets; they are classes loaded and invoked by Qwicap's own servlet class. In order for Qwicap's servlet to load and execute your application's main class, it must be able to determine the identity of that class.

Beginning with version 1.4, Qwicap will automatically scan all of your application's classes in search of one that has a "public static void main(String[])" method, and which also references the class "edu.utexas.its.eis.tools.qwicap.servlet.Qwicap". A class meeting those criteria is considered to be the entry point of your web application. Qwicap will begin its search for the entry point by scanning all of the classes in your application's "WEB-INF/classes" directory hierarchy. If that fails, it will scan all of the classes in the JAR files located in your application's "WEB-INF/lib" directory. Either scan will fail if no entry point is found, or if more than one entry point is located. If either scan is successful in locating your application's entry point, Qwicap will begin the execution of your application. If not, it will throw an explanatory exception.

That automatic entry point detection feature usually allows developers to use the default web application deployment descriptor ("web.xml" file) shown below in all of their Qwicap web applications, without modification. Using that default deployment descriptor, a web application is accessed with a URL specifying the host, the optional port, and the name of the web application, for example: "http://localhost:8080/mywebapp".

Default "web.xml" File for Qwicap 1.4 Applications

<?xml version="1.0" encoding="UTF-8"?>    

<!DOCTYPE web-app 
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"> 

<web-app>

    <display-name>Qwicap Web Application</display-name>
    <description>
        A web application built on the Quick Web Interface for Conventional 
        Applications (QWICAP), using Qwicap's default, general-purpose 
        "web.xml" file.
    </description>

    <context-param>
        <param-name>qwicap-development-mode</param-name>
        <param-value>false</param-value>
        <description>
            If this value is "true", when reporting an exception Qwicap
            includes the error message from the exception in the user-
            visible message that it displays, and it also embeds into a 
            comment block in the web page the entire chain of stack 
            traces from the exception. This can be useful during the 
            development and debugging of a web application, but is a bad 
            practice from a security standpoint.
            
            If this value is "false", Qwicap only reports opaque "incident
            codes" to the user, and never includes stack traces in the 
            pages. This gives would-be attackers vastly less information 
            with which to guide their attacks.
            
            If this context parameter is omitted, development mode is 
            considered to be disabled.
        </description>
    </context-param>
    
    <context-param>
        <param-name>qwicap-threads-minimum</param-name>
        <param-value>0</param-value>
        <description>
            The number of threads initially present in Qwicap's thread 
            pool. This value must not be greater than 
            "qwicap-threads-spare-maximum".
        </description>
    </context-param>
    
    <context-param>
        <param-name>qwicap-threads-spare-maximum</param-name>
        <param-value>0</param-value>
        <description>
            The maximum number of spare threads that Qwicap will retain 
            in its thread pool. This value must not be greater than 
            "qwicap-threads-maximum".
        </description>
    </context-param>
    
    <context-param>
        <param-name>qwicap-threads-maximum</param-name>
        <param-value>1000</param-value>
        <description>
            The maximum size of the Qwicap thread pool. This is the 
            maximum number of concurrent users this web application 
            will be able to support.
        </description>
    </context-param>
    
    <context-param>
        <param-name>qwicap-thread-stack-kilobytes</param-name>
        <param-value>0</param-value>
        <description>
            The amount of stack space allocated to each thread in the 
            thread pool. A value of zero causes the platform-specific 
            default stack size to be used. Platforms are free to 
            ignore, or change, the stack size setting, no matter what 
            value is specified.
        </description>
    </context-param>
    
    <servlet>
        <servlet-name>QwicapDefault</servlet-name>
        <display-name>Qwicap Web Application Component</display-name>
        <description>
            A web application component built on the Quick Web Interface for 
            Conventional Applications (QWICAP).
        </description>
        <servlet-class>edu.utexas.its.eis.tools.qwicap.servlet.QwicapServlet</servlet-class>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>QwicapDefault</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    
    <session-config>
        <session-timeout>10</session-timeout>    <!-- 10 minutes -->
    </session-config>
    
</web-app>

Customizable Items

Manually Specifying an Application's Entry Point

In situations where Qwicap's automatic entry point detection feature is inadequate to your needs, the entry point can be specified manually by adding an "init-param" tag inside the "servlet" tag, as illustrated below. The content of the "param-value" tag should be the fully-qualified name of the class in your application that contains the "public static void main(String[])" method at which the execution of your web application should begin.

    <servlet>
        <servlet-name>QwicapDefault</servlet-name>
        <display-name>Qwicap Web Application Component</display-name>
        <description>
            A web application component built on the Quick Web Interface for 
            Conventional Applications (QWICAP).
        </description>
        <servlet-class>edu.utexas.its.eis.tools.qwicap.servlet.QwicapServlet</servlet-class>
        <init-param>
            <param-name>QwicapClientClassName</param-name>
            <param-value>com.mycompany.myproject.MyMainClass</param-value>
            <description>Manually specified application entry point.</description>
        </init-param>
    </servlet>

Specifying Multiple Servlets

Web application deployment descriptors are allowed to include multiple "servlet" tags. Qwicap 1.4, however, supports only a single servlet in each web application. Specifying more than one servlet will produce undefined, but assuredly bad, results. So, don't do that. Support for multiple servlets (for Qwicap's purposes, that's effectively the same as combining several different web applications in one) may be restored in the future.

Valid XHTML 1.0! Valid CSS!