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: ...

Get Apache Karaf Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.