// Create root context and add the ProxyServlet.Transparent to it
ServletContextHandler contextHandler = new ServletContextHandler();
server.setHandler(contextHandler);
contextHandler.setContextPath("/");
ServletHolder servletHolder = contextHandler.addServlet(
ProxyServlet.Transparent.class, "/*");
// Configure servlet to forward to the root of the original server
servletHolder.setInitParameter(
"ProxyTo",
"http://" + request.getLocalAddr() + ":"
+ request.getLocalPort() + "/");
// Configure servlet to strip beginning of paths
servletHolder.setInitParameter("Prefix", "/proxypath/");
// Start the server
try {
server.start();
} catch (Exception e) {