I have a Web app with several servlets configured in my OSGI-INF/blueprint/web-blueprint.xml using pax web. The web app consists of two pages /LoginPage.html and /Dashboard.html, but the latter supports several views, each associated with an own angular controller and related backend servlet.
I can reach the two pages by the URLs https://<ip>:<port>/LoginPage.html and https://<ip>:<port>/Dashboard.html. Accessing https://<ip>:<port>/ redirects to https://<ip>:<port>/LoginPage.html.
If we call https://<ip>:<port>/ the base URL, I would like now to change this base URL to something like https://<ip>:<port>/test/ so that
- the login and dashboard pages are available under
https://<ip>:<port>/test/LoginPage.htmlandhttps://<ip>:<port>/test/Dashboard.htmlrespectively, and https://<ip>:<port>/testsimply redirects tohttps://<ip>:<port>/test/LoginPage.html.
Because the file etc/org.ops4j.pax.web.cfg specifies etc/jetty.xml as its config file, I was assuming that I can configure this in jetty.xml. The current jetty.xml is the standard one. jetty documentation says that one can set the context path by adding the following:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/test</Set>
</Configure>
But, adding simply the above to the end of the standard jetty conf file causes that my web pages are not reachable at all. I cannot find any further documentation or example how I could get this work...
I would appreciate any help very much!
Please specify which Pax Web version you're using. In Pax Web 8, whiteboard context configuration and selection is fully implemented.
There's a blueprint example that declares servlets, filters, error pages and welcome files but it doesn't do what you want (you want to register a
ServletContextHelperwhiteboard service).There's also a whiteboard non-blueprint sample that registers a context using non-standard
org.ops4j.pax.web.service.whiteboard.HttpContextMapping.So I can't point you to proper sample, but in short words, you need three things:
org.osgi.service.http.context.ServletContextHelperYou have to extend this class, because it's abstract. You could also reuse
org.ops4j.pax.web.service.spi.context.DefaultServletContextHelperPax Web 8 correctly handles context selection using standard Whiteboard service registration properties.