Book Image

APACHE KARAF COOKBOOK

Book Image

APACHE KARAF COOKBOOK

Overview of this book

Table of Contents (17 chapters)
Apache Karaf Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Building a Servlet 3.0 annotated web application with Apache Karaf


With the Servlet 3.0 API, it's possible to have web archives only with annotated servlets and omit a web.xml file, or at least omit the configuration of the application within a web.xml file.

Getting ready

As usual, you will find the code for this recipe at the GitHub location at https://github.com/jgoodyear/ApacheKarafCookbook/tree/master/chapter4/chapter4-recipe9.

How to do it…

As with the Building a standard web project to host in Apache Karaf recipe, we just build another WAB bundle. Only this time, we have a web.xml file containing only the definition for the welcome-file-list method and annotated servlets:

  1. The first step is defining the web.xml file. This can be done as follows:

    <web-app 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"
        version="3.0">
    
        &lt...