/** Add a context handler. * @param contextPath The context path to add * @return * @throws IllegalAccessException * @throws InstantiationException */ public ContextHandler addContext(String contextPath,String resourceBase) { try { ContextHandler context = (ContextHandler)_contextClass.newInstance(); context.setContextPath(contextPath); context.setResourceBase(resourceBase); addHandler(context); return context; } catch (Exception e) { Log.warn(e); throw new Error(e); } }
private void deploy(String filename) throws Exception { ContextHandler context=createContext(filename); Log.info("Deploy "+filename+" -> "+ context); _contexts.addHandler(context); _currentDeployments.put(filename,context); if (_contexts.isStarted()) context.start(); }
servlet.addServletWithMapping("org.mortbay.jetty.servlet.DefaultServlet", URIUtil.SLASH); context.setHandler(servlet); contexts.addHandler(context); webapp.setResourceBase(args[2]); webapp.setContextPath(URIUtil.SLASH); contexts.addHandler(webapp);
webAppContext.setDescriptor(appDir + "/" + name + "/WEB-INF/web.xml"); contexts.addHandler(webAppContext); webServer.setHandler(contexts);
webAppContext.setDescriptor(appDir + "/" + name + "/WEB-INF/web.xml"); contexts.addHandler(webAppContext); webServer.setHandler(contexts);
public static void main(String[] args) throws Exception { Server server = new Server(8080); ContextHandlerCollection contexts = new ContextHandlerCollection(); server.setHandler(contexts); Context root = new Context(contexts,"/",Context.SESSIONS); root.addServlet(new ServletHolder(new HelloServlet("Ciao")), "/*"); Context other = new Context(contexts,"/other",Context.SESSIONS); other.addServlet("org.mortbay.jetty.example.ManyServletContexts$HelloServlet", "/*"); StatisticsHandler stats = new StatisticsHandler(); contexts.addHandler(stats); Context yetanother =new Context(stats,"/yo",Context.SESSIONS); yetanother.addServlet(new ServletHolder(new HelloServlet("YO!")), "/*"); server.start(); server.join(); }
protected Context getContext() { if (getWebAppcontextPath() != null) { m_context = new WebAppContext( null,ConfigUtils .getInitialPropertyExpanded(getContextPath())); m_context.setResourceBase(getResourceBase()); getContexts().addHandler(m_context); getServer().setHandler(getContexts()); } else if (m_context == null) { getServer().setHandler(getContexts()); m_context = new Context(m_contexts, getContextPath(), Context.SESSIONS); if (getResourceBase() != null) { m_context.setResourceBase(getResourceBase()); } } return m_context; }