I'm using embedded Jetty with a WebAppContext. I now need to add a MovedContextHandler, but I'm not sure where it fits in the server/servlet/context stack. Our code currently looks roughly like this:
Server server = new Server();
WebAppContext webapp = new WebAppContext();
GzipHandler gzip = new GzipHandler();
So far I've tried:
(1) new MovedContextHandler(webapp/server, ...);
This solution doesn't work because it calls setHandler on the webapp/server, removing the sessionHandler/gzipHandler, respectively.
(2) webapp.insertHandler(new MovedContextHandler());
This doesn't work because movedCtxHandler.getHandler() returns the Redirector, which doesn't implement HandlerWrapper.
So where does MovedContextHandler go in the stack? All of my searches have only led me to XML configuration.
p.s. I'm happy to ask on StackOverflow instead if that's the preferred venue for Jetty questions these days.