Skip to content

Home

Introduction

Development

Overview

IDEs

Services

Service manager

API Explorer

Integrate package deployment descriptor

In Java EE, the deployment descriptor file /WEB-INF/web.xml describes how an application should be deployed to a servlet container like Tomcat, Jetty, or JBoss. The aforementioned file defines the servlets that exist in the web application (via <servlet> tags) and specifies which servlet the container should use according to the URL mapping being accessed (supported mappings by the servlet are defined in <servlet-mapping> elements)1.

Example web.xml
 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
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                             http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5">
    <display-name>My Web Application</display-name>

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value></param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

In the configuration above, a DispatcherServlet is declared and mapped as the default and only servlet2 of the web application. The DispatcherServlet is Spring MVC's front controller; its job is to take an incoming request and delegate the request to the right handler(s) so that the request can be processed and the server could respond appropriately. Since it is the default and only servlet in the configuration above, it will be handling all requests received by the container; which is also the case in most Spring MVC-based web applications.

Once an Integrate package's web directory exists, even if it's empty, TORO Integrate will treat that package as a separate web application. Furthermore, it is possible to create your own custom /WEB-INF/web.xml and override the default /WEB-INF/web.xml TORO Integrate creates for you if your package's /WEB-INF/web.xml does not exist in the web directory.

Why would I want to create my own /WEB-INF/web.xml file?

Customizing a package's deployment descriptor is not required; in fact, TORO recommends leaving it empty unless you want to customize behavior. However, creating your own custom /WEB-INF/web.xml enables you to configure advanced behavior for your web application via adding things such as other filters and servlets.

Procedure

  1. Create the Integrate package's web directory, if it doesn't exist yet.
  2. Create the /WEB-INF directory under the web directory, and then create and define the web.xml file under /WEB-INF.

    Other configuration files may be required

    Depending on the web application configuration you're going for, there may be other configuration files required. For example, if you have defined a context parameter named contextConfigLocation whose value is /WEB-INF/root-configuration.xml, then this file must exist.

  3. After finalizing your configuration files, restart the package in order to reflect your changes.


  1. Sheng. (2015, August). Understand web.xml in Spring MVC project [Blog post]. Retrieved from http://shengwangi.blogspot.com/2015/08/understand-webxml-in-spring-mvc-project.html 

  2. /, being the servlet's URL pattern, indicates that it is the default servlet of the web application.