Standard web.xml Configuration

Chrysalis requires certain configuration settings in the standard web application deployment (/WEB-INF/web.xml). Exactly how you configure the web.xml depends on whether you are using a Servlet 2.2 container or a Servlet 2.3+ container.

The Chrysalis distribution has examples of both in the src/conf directory. In most cases, the example web.xml files will work unchanged or with minor modifications. The configurations are not application-specific; all application specific configuration information in Chrysalis goes in the ChrysalisConfig.xml file and the chrysalis.xml files in the individual controller and JavaBean packages.

Servlet 2.2 Container web.xml

For Servlet 2.2, you must configure the FilterServlet to match the URL patterns *.cmd and *view:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Example configuration for Servlet 2.2 Containers -->

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

<web-app>
  <description>Chrysalis-based application.</description>

  <servlet>
    <servlet-name>FilterServlet</servlet-name>
    <servlet-class>org.chwf.servlet.filter.FilterServlet</servlet-class>
  </servlet>
    
  <servlet-mapping>
    <servlet-name>FilterServlet</servlet-name>
    <url-pattern>*.cmd</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>FilterServlet</servlet-name>
    <url-pattern>*.view</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.view</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>

The FilterServlet is Chrysalis's Filter Micro-Container; it adds filter support to the Servlet 2.2 container. To configure the individual filters, you must also have a /WEB-INF/filter.xml configuration file:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Example configuration for Servlet 2.2 Containers -->

<web-app>
  <filter>
    <filter-name>CommandFilter</filter-name>
    <filter-class>org.chwf.servlet.engine.CommandFilter</filter-class>
    <url-pattern>*.cmd</url-pattern>
  </filter>
  <filter>
    <filter-name>ViewFilter</filter-name>
    <filter-class>org.chwf.servlet.view.ViewFilter</filter-class>
    <url-pattern>*.view</url-pattern>
  </filter>
 
  <resource-mapping>
    <mapped-extension>*.view</mapped-extension>
    <resource-extension>*.jsp</resource-extension>
  </resource-mapping>
</web-app>

For more information on the Filter Micro-Container, see the documentation on the filter.xml and the Chrysalis Architecture.

Servlet 2.3+ Container web.xml

For Servlet 2.3+, you can configure the CommandFilter and ViewFilter for the "*.cmd" and "*.jsp" URL patterns in the web.xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Example configuration for Servlet 2.3+ Containers -->

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

<web-app>
  <description>Chrysalis-based application.</description>

  <filter>
    <filter-name>CommandFilter</filter-name>
    <filter-class>org.chwf.servlet.engine.CommandFilter</filter-class>
  </filter>
  <filter>
    <filter-name>ViewFilter</filter-name>
    <filter-class>org.chwf.servlet.view.ViewFilter</filter-class>
  </filter>
 
  <filter-mapping>
    <filter-name>CommandFilter</filter-name>
    <url-pattern>*.cmd</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>ViewFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
  </filter-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>

If you want to support the same "*.view" extension used in Servlet 2.2 Chrysalis applications, you must add the "*.view" pattern to the ViewFilter, and add the ResourceMapper filter, also for "*.view".

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Example configuration for Servlet 2.3+ Containers -->

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

<web-app>
  <description>Chrysalis-based application.</description>

  <filter>
    <filter-name>CommandFilter</filter-name>
    <filter-class>org.chwf.servlet.engine.CommandFilter</filter-class>
  </filter>
  <filter>
    <filter-name>ViewFilter</filter-name>
    <filter-class>org.chwf.servlet.view.ViewFilter</filter-class>
  </filter>
  <filter>
    <filter-name>ResourceMapper</filter-name>
    <filter-class>org.chwf.servlet.filter.ResourceMapper</filter-class>
  </filter>
 
  <filter-mapping>
    <filter-name>CommandFilter</filter-name>
    <url-pattern>*.cmd</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>ViewFilter</filter-name>
    <url-pattern>*.view</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>ViewFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>ResourceMapper</filter-name>
    <url-pattern>*.view</url-pattern>
  </filter-mapping>

  <welcome-file-list>
    <welcome-file>index.view</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>

For the resource mapping to work, you will need a small filter.xml configuration file to define the resource extension mapping:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Example configuration for Servlet 2.3+ Containers -->

<web-app>
  <resource-mapping>
    <mapped-extension>*.view</mapped-extension>
    <resource-extension>*.jsp</resource-extension>
  </resource-mapping>
</web-app>