How to retrieve BundleContext in Servlet

The BundleContext instance can be retrieved via the servlet context.

HttpServletRequest request = ...
BundleContext bundlecontext = (BundleContext) request.getServletContext().getAttribute("osgi-bundlecontext");