use of org.eclipse.jetty.servlet.DefaultServlet in project Synthese_2BIN by TheYoungSensei.
the class MyServer method main.
public static void main(String[] args) throws Exception {
// lie le server � un port
Server server = new Server(8000);
// instancie un WebAppContext pour configurer le server
WebAppContext context = new WebAppContext();
// O� se trouvent les fichiers (ils seront servis par un DefaultServlet)
context.setResourceBase("www");
// MaServlet r�pondra aux requ�tes commen�ant par /chemin/
context.addServlet(new ServletHolder(new MachineServlet()), "/Machine");
// Le DefaultServlet sert des fichiers (html, js, css, images, ...). Il est en g�n�ral ajout� en dernier pour que les autres servlets soient prioritaires sur l�interpr�tation des URLs.
context.addServlet(new ServletHolder(new DefaultServlet()), "/");
// ce server utilise ce context
server.setHandler(context);
// allons-y
server.start();
}
use of org.eclipse.jetty.servlet.DefaultServlet in project jena by apache.
the class SPARQLServer method addContent.
private static void addContent(ServletContextHandler context, String pathSpec, String pages) {
DefaultServlet staticServlet = new DefaultServlet();
ServletHolder staticContent = new ServletHolder(staticServlet);
staticContent.setInitParameter("resourceBase", pages);
// Note we set GZip to false for static content because the Jetty
// DefaultServlet has
// a built-in GZip capability that is better for static content than the
// mechanism the
// GzipFilter uses for dynamic content
addServlet(context, staticContent, pathSpec, false);
}
use of org.eclipse.jetty.servlet.DefaultServlet in project samza by apache.
the class TestYarnContainerHeartbeatServlet method setup.
@Before
public void setup() throws Exception {
container = mock(YarnContainer.class);
ReadableMetricsRegistry registry = new MetricsRegistryMap("test-registry");
yarnAppState = new YarnAppState(-1, ConverterUtils.toContainerId("container_1350670447861_0003_01_000001"), "testHost", 1, 1);
webApp = new HttpServer("/", 0, "", new ServletHolder(new DefaultServlet()));
webApp.addServlet("/", new YarnContainerHeartbeatServlet(yarnAppState, registry));
webApp.start();
mapper = new ObjectMapper();
}
use of org.eclipse.jetty.servlet.DefaultServlet in project camel by apache.
the class WebsocketComponent method createStaticResourcesServer.
protected Server createStaticResourcesServer(Server server, ServletContextHandler context, String home) throws Exception {
context.setContextPath("/");
SessionHandler sh = new SessionHandler();
context.setSessionHandler(sh);
if (home != null) {
String[] resources = home.split(":");
if (LOG.isDebugEnabled()) {
LOG.debug(">>> Protocol found: " + resources[0] + ", and resource: " + resources[1]);
}
if (resources[0].equals("classpath")) {
context.setBaseResource(new JettyClassPathResource(getCamelContext().getClassResolver(), resources[1]));
} else if (resources[0].equals("file")) {
context.setBaseResource(Resource.newResource(resources[1]));
}
DefaultServlet defaultServlet = new DefaultServlet();
ServletHolder holder = new ServletHolder(defaultServlet);
// avoid file locking on windows
// http://stackoverflow.com/questions/184312/how-to-make-jetty-dynamically-load-static-pages
holder.setInitParameter("useFileMappedBuffer", "false");
context.addServlet(holder, "/");
}
server.setHandler(context);
return server;
}
use of org.eclipse.jetty.servlet.DefaultServlet in project zeppelin by apache.
the class ZeppelinServer method setupWebAppContext.
private static WebAppContext setupWebAppContext(ContextHandlerCollection contexts, ZeppelinConfiguration conf) {
WebAppContext webApp = new WebAppContext();
webApp.setContextPath(conf.getServerContextPath());
File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR));
if (warPath.isDirectory()) {
// Development mode, read from FS
// webApp.setDescriptor(warPath+"/WEB-INF/web.xml");
webApp.setResourceBase(warPath.getPath());
webApp.setParentLoaderPriority(true);
} else {
// use packaged WAR
webApp.setWar(warPath.getAbsolutePath());
File warTempDirectory = new File(conf.getRelativeDir(ConfVars.ZEPPELIN_WAR_TEMPDIR));
warTempDirectory.mkdir();
LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
webApp.setTempDirectory(warTempDirectory);
}
// Explicit bind to root
webApp.addServlet(new ServletHolder(new DefaultServlet()), "/*");
contexts.addHandler(webApp);
webApp.addFilter(new FilterHolder(CorsFilter.class), "/*", EnumSet.allOf(DispatcherType.class));
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", Boolean.toString(conf.getBoolean(ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED)));
return webApp;
}
Aggregations