uCosminexus Application Server, Web Service Development Guide

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

12.3.3 Creating web.xml

You create web.xml that is required as a WAR file component.

The example of creating web.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<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">
 
    <description>Sample web service &quot;tutorial&quot;</description>
    <display-name>Sample_web_service_jaxrs_tutorial</display-name>
    <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>com.sample.resources;com.sample.providers</param-value>
        </init-param>
        <!-- POJO JSON support web.xml configuration -->
        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</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.

Save the created web.xml in the c:\temp\jaxrs\works\tutorial\server\WEB-INF\ directory in the UTF-8 format. For details on the web.xml settings, see 3.4 Creating web.xml.