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:com.bitran.config.Inicializador.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.scan("com.bitran");
    sc.addListener(new ContextLoaderListener(ctx));
    Dynamic servlet = sc.addServlet("appServlet", new DispatcherServlet(ctx));
    servlet.setAsyncSupported(true);/*w w  w .  ja va2 s  . c o  m*/
    servlet.setLoadOnStartup(1);
    servlet.addMapping("*.action");
}

From source file:com.chevres.config.WebInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(Config.class);
    ctx.setServletContext(servletContext);
    Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);/*from   w  ww  .ja va 2 s  .c o  m*/
}

From source file:com.shadows.liquiblq.webapi.config.WebAppInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(AppConfig.class);
    ctx.setServletContext(servletContext);
    Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);/*from   w w  w . j  a v a 2  s.  c o  m*/
}

From source file:$.SpringAppInitializer.java

@Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        WebApplicationContext context = getContext();
        servletContext.addListener(new ContextLoaderListener(context));

        ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet",
                new DispatcherServlet(context));

        dispatcher.setLoadOnStartup(1);/*from  w w w  .j av  a 2  s .c  o  m*/
        dispatcher.addMapping(MAPPING_URL);
    }

From source file:com.github.djabry.platform.service.config.TestInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    WebApplicationContext context = getContext();
    servletContext.addListener(new ContextLoaderListener(context));
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet",
            new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);/*  www.j a  v a  2 s .  co m*/
    dispatcher.addMapping("/*");

}

From source file:com.chuangtc.config.SpringWebInitializer.java

public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(AppConfig.class);
    ctx.setServletContext(servletContext);

    Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);/*w w  w. j  av  a  2 s .  c  om*/

}

From source file:com.triage.springweb.WebInitializer.java

public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(Config.class);

    ctx.setServletContext(servletContext);

    Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);//  w  ww.  j a  va  2 s .  co m

}

From source file:eu.agilejava.spring4.config.ApplicationInitializer.java

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

    WebApplicationContext context = createWebAppContext();
    servletContext.addListener(new ContextLoaderListener(context));

    ServletRegistration.Dynamic registration = servletContext.addServlet("dispatcher",
            new DispatcherServlet(context));
    registration.setLoadOnStartup(1);//from w  ww. j  a v a  2  s .  c  o m
    registration.addMapping("/api/*");

}

From source file:com.navita.mavenproject4.config.WebInit.java

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

    AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext();
    dispatcherServlet.register(MvcConfig.class);
    ServletRegistration.Dynamic dispatcher = sc.addServlet("dispatcher",
            new DispatcherServlet(dispatcherServlet));

    dispatcher.setLoadOnStartup(1);//from w  ww. ja v  a 2  s.  co  m
    dispatcher.addMapping("/");

    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(JpaConfig.class);
    sc.addListener(new ContextLoaderListener(rootContext));

}

From source file:eu.agilejava.mvc.config.ApplicationInitializer.java

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

    WebApplicationContext context = createWebAppContext();
    servletContext.addListener(new ContextLoaderListener(context));

    ServletRegistration.Dynamic registration = servletContext.addServlet("dispatcher",
            new DispatcherServlet(context));
    registration.setLoadOnStartup(1);/*w w  w .  ja va 2 s  .c o  m*/
    registration.addMapping("/hello");

}