uCosminexus Application Server, Web Service Development Guide

[Contents][Glossary][Index][Back][Next]

11.2 Creating web.xml

This section describes the web.xml file included in a WAR file that is used in a Web resource.

You name the file as web.xml and store it under the WEB-INF directory that configures the WAR files. Storing the web.xml file is mandatory.

The following sections describe both the definitions required for executing a Web Service and an example of a web.xml file.

Organization of this section
(1) Definitions required for executing a Web Service
(2) Example of web.xml

(1) Definitions required for executing a Web Service

Create the web.xml file so that the file satisfies the following conditions:

(2) Example of web.xml

An example of web.xml is as follows:

<web-app version="3.0"
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
 <servlet>
  <servlet-name>CosminexusJaxrsServlet</servlet-name>
  <servlet-class>
   com.cosminexus.jersey.spi.container.servlet.ServletContainer
  </servlet-class>
  <init-param>
   <param-name>com.sun.jersey.config.property.packages</param-name>
   <param-value>org.test.resources1;org.test.resources2</param-value>
  </init-param>
 </servlet>
 <servlet-mapping>
  <servlet-name>CosminexusJaxrsServlet</servlet-name>
  <url-pattern>/*</url-pattern>
 </servlet-mapping>
</web-app>

When creating web.xml of version 2.5, specify 2.5 in the version attribute of the web-app element and specify http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd as the second location information in the xsd:schemaLocation attribute.

In this example, the following Web resources will be published assuming that org.test.resources1.ResourceA, org.test.resources1.ResourceB, org.test.resources2.ResourceC, and org.test.resources3.ResourceD are included in the WAR file: