Building an application with custom HttpContext with Apache Karaf
All previous recipes have covered how to register servlets and filters, and all from within the same bundle bound to a default HttpContext. If no other HttpContext is defined, DefaultHttpContext is created while registering a servlet or resource. With this recipe, we will work with a custom HttpContext.
Getting ready
As this recipe is a specialization of the previous recipes, you'll find the source code for it in the Building a Http Service with the Whiteboard pattern in Apache Karaf recipe. As usual, the recipe demands the successful installation of the http-whiteboard
feature; how this can be achieved is explained in the Installing extended Http Service in Apache Karaf recipe. The source code in this recipe is reduced to the important sections. The full sources can be found at https://github.com/jgoodyear/ApacheKarafCookbook/tree/master/chapter4/chapter4-recipe4.
How to do it…
The first step is defining properties. As with servlets...