When registering servlets on the whiteboard, pax-web-whiteboard-extender will pick it up and make it available on Jetty. This is described in http://ops4j.github.io/pax/web/SNAPSHOT/#_servlets. I believe the way-of-least-surprise would be this
If the bundle registering the servlet is a WAB (i.e. it exposes a service of type org.ops4j.pax.web.service.WebAppDependencyHolder), then associate the servlet with the HttpContext that already exists for the bundle
If the bundle is not a WAB, create a new HttpContext and associate the servlet with this context (unless ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID is defined of course).
Point 2. is the implementation for all servlets today. This has several drawbacks
Any security constraints or other configuration in web.xml for the WAB will not be applied to the servlet
Any configuration in jetty-web.xml for the WAB will not be applied to the servlet
Todays impementation assumes use of ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID in order to associate a servlet with a HttpContext. This is fine and well, but the HttpContext registered by pax-web for the WAB doesn't have a context id, thus making it impossible to associate a servlet with it.
Make it possible to associate servlets with the HttpContext already created for a WAB through the context id. Maybe by registering the context as a service with that property on the bundle?
Introduce the default behaviour described above where servlets are default associated with existing HttpContexts for WABs