Example usage for javax.servlet ServletContext addServlet

List of usage examples for javax.servlet ServletContext addServlet

Introduction

In this page you can find the example usage for javax.servlet ServletContext addServlet.

Prototype

public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass);

Source Link

Document

Adds the servlet with the given name and class type to this servlet context.

Usage

From source file:be.wolkmaan.klimtoren.web.config.WebAppInitializer.java

public void zkLoaderServlet(ServletContext servletContext) {
    ServletRegistration.Dynamic servlet = servletContext.addServlet("zkLoader", new DHtmlLayoutServlet());
    servlet.setInitParameter("update-uri", "/zkau");
    servlet.setLoadOnStartup(1);/*  ww w  . j av  a2  s .c  om*/
    servlet.addMapping("*.zul");
    servlet.addMapping("*.zhtml");
    servlet.addMapping("/zk/*");
}

From source file:be.wolkmaan.klimtoren.web.config.WebAppInitializer.java

public void logbackServlet(ServletContext servletContext) {
    ServletRegistration.Dynamic servlet = servletContext.addServlet("logbackStatus",
            new ch.qos.logback.classic.ViewStatusMessagesServlet());
    servlet.setLoadOnStartup(3);//  ww w .j  a va 2s  .  c  o  m
    Set<String> mappingConflicts = servlet.addMapping("/admin/logbackStatus/*");

    if (!mappingConflicts.isEmpty()) {
        for (String s : mappingConflicts) {
            logger.error("Mapping conflict: " + s);
        }
        throw new IllegalStateException("servlet cannot be mapped");
    }
}

From source file:test.config.WebAppInitializer.java

private void setupJsonScenario(ServletContext servletContext) {

    Dynamic servlet;// www .j  ava2 s.  c om
    servlet = servletContext.addServlet("JsonA", new DispatchingAsyncServlet("A", "/jsonScenarioB", null));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/jsonScenarioA/*");

    servlet = servletContext.addServlet("JsonB", new JsonServlet());
    servlet.setAsyncSupported(true);
    servlet.addMapping("/jsonScenarioB/*");
}

From source file:test.config.WebAppInitializer.java

private void setupRedirectScenario(ServletContext servletContext) {

    Dynamic servlet;/*from  ww  w. j a  va2s  .  c  o  m*/
    servlet = servletContext.addServlet("RedirectA",
            new DispatchingAsyncServlet("A", "/redirectScenarioB/b?b=B", null));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/redirectScenarioA/*");

    servlet = servletContext.addServlet("RedirectB",
            new RedirectingServlet("B", "../redirectScenarioC/c?c=C", null));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/redirectScenarioB/*");

    servlet = servletContext.addServlet("RedirectC", new ForwardingServlet("C", "/WEB-INF/page.jsp", null));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/redirectScenarioC/*");
}

From source file:org.bitcoinrt.config.WebSocketServletInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    TomcatBitcoinServlet servlet = new TomcatBitcoinServlet();

    Dynamic registration = servletContext.addServlet("ws", servlet);
    registration.addMapping("/tomcat");
    registration.setLoadOnStartup(1);//from  www.  j ava 2  s  .co m

    Broadcaster broadcaster = servlet;

    AbstractMtgoxClient mtgoxClient = new StubMtgoxClient(broadcaster);
    //      AbstractMtgoxClient mtgoxClient = new JettyMtgoxClient(broadcaster);
    //      AbstractMtgoxClient mtgoxClient = new AsyncHttpClientMtgoxClient(broadcaster);

    servletContext.addListener(new MtGoxContextListener(mtgoxClient));
}

From source file:org.jbr.commons.container.http.StandardWebAppInitializer.java

protected void createDispatcherServlet(final ServletContext servletContext,
        final WebApplicationContext rootContext) {
    final ServletRegistration.Dynamic appServlet = servletContext.addServlet("dispatcher",
            new DispatcherServlet(rootContext));
    appServlet.setLoadOnStartup(1);/*from w  w  w.j av a 2  s.  c  o m*/
    appServlet.addMapping("/");
}

From source file:com.rockagen.gnext.main.BootStrap.java

protected void addServlet(final ServletContext ctx) {
    DispatcherServlet ds = new DispatcherServlet(rootContext);
    // Spring mvc
    ctx.addServlet("spring-mvc", ds).addMapping("/");

    StatViewServlet druid = new StatViewServlet();

    // Druid view
    ctx.addServlet("druid", druid).addMapping("/druid/*");

}

From source file:com.github.mrstampy.gameboot.otp.websocket.WebSocketTestInitializer.java

@Override
public void onStartup(ServletContext container) throws ServletException {
    log.info("********************** YEP, ITS WORKING ******************");

    ServletRegistration.Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet());
    registration.setLoadOnStartup(1);//from  w  w w  .  j av a2s . c  om
    registration.addMapping("/");
}

From source file:test.config.WebAppInitializer.java

private void setupDispatchScenario(ServletContext servletContext) {

    CountDownLatch latch = new CountDownLatch(1);

    Dynamic servlet;//ww w . j a va 2  s  . co m
    servlet = servletContext.addServlet("DispA", new ForwardingServlet("A", "/dispScenarioB/b?b=B", latch));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/dispScenarioA/*");

    servlet = servletContext.addServlet("DispB", new ForwardingServlet("B", "/dispScenarioC/c?c=C", null));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/dispScenarioB/*");

    servlet = servletContext.addServlet("DispC",
            new DispatchingAsyncServlet("C", "/dispScenarioD/d?d=D", latch));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/dispScenarioC/*");

    servlet = servletContext.addServlet("DispD", new ForwardingServlet("D", "/WEB-INF/page.jsp", null));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/dispScenarioD/*");
}

From source file:test.config.WebAppInitializer.java

private void setupForwardScenario(ServletContext servletContext) {

    CountDownLatch latch = new CountDownLatch(1);

    Dynamic servlet;/* w ww . ja  v  a2s.  co m*/
    servlet = servletContext.addServlet("ForwardA",
            new ForwardingServlet("A", "/forwardScenarioB/b?b=B", latch));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/forwardScenarioA/*");

    servlet = servletContext.addServlet("ForwardB",
            new ForwardingServlet("B", "/forwardScenarioC/c?c=C", null));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/forwardScenarioB/*");

    servlet = servletContext.addServlet("ForwardC",
            new ForwardingAsyncServlet("C", "/forwardScenarioD/d?d=D", latch));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/forwardScenarioC/*");

    servlet = servletContext.addServlet("ForwardD", new ForwardingServlet("D", "/WEB-INF/page.jsp", null));
    servlet.setAsyncSupported(true);
    servlet.addMapping("/forwardScenarioD/*");
}