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.se.configuracion.WebInitializer.java

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

}

From source file:org.emmanuel.spring.chat.config.webxml.WebXml.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);/*w  w w  .j  av  a  2s.c om*/
    dispatcher.addMapping(MAPPING_URL);
}

From source file:com.library.bookarticlelibrary.WebAppInitializer.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);/*w ww .j av a2  s  . c  om*/
    dispatcher.addMapping("/");
    dispatcher.addMapping("*.css");
    dispatcher.addMapping("*.js");
    dispatcher.addMapping("*.pdf");
    dispatcher.addMapping("*.json");
}

From source file:com.sbtn.spring.config.WebInitializer.java

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

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

    ctx.setServletContext(sc);/*ww  w .j  a  va  2 s.  c o  m*/

    Dynamic servlet = sc.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);

}

From source file:ch.thp.proto.spring.time.web.config.ServletAppInitializer.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 ww .  j a  v  a2s .c  om*/
    dispatcher.addMapping("/*");
}

From source file:com.zbum.example.springweb.initializer.WebInitializer.java

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 ww  .  ja va2s  .c  o m*/
    dispatcher.addMapping(MAPPING_URL);
}

From source file:de.asgarbayli.rashad.hbd.config.WebInitializer.java

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

From source file:ui.config.WebAppInitializer.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(ApplicationConfig.class);
    ctx.setServletContext(sc);/*from  ww  w .  ja  v a  2 s.  c o  m*/

    Dynamic dynamic = sc.addServlet("UserController", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);
}

From source file:ca.n4dev.dev.worktime.config.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));

    //servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain")).addMappingForUrlPatterns(null, false, "/*");

    dispatcher.setLoadOnStartup(1);/*from  w  w  w.  j  a  v a  2s  .  co m*/
    dispatcher.addMapping(MAPPING_URL);
}

From source file:org.efoe.poc.springws.provider.xmlbeans.initializer.WebXml.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);/*  ww w. j  a v a  2s  . com*/
    dispatcher.addMapping(MAPPING_URL);

    ServletRegistration.Dynamic ws = servletContext.addServlet("MessageDispatcherServlet",
            new MessageDispatcherServlet(context));
    ws.setInitParameter("transformWsdlLocations", "true");
    ws.addMapping("/services/*");
}