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:org.beast.project.template.initializer.WebxmlConfig.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   www.  java2s  .  com*/
    dispatcher.addMapping(MAPPING_URL);

    ServletRegistration.Dynamic ws = servletContext.addServlet("MessageDispatcherServlet",
            new MessageDispatcherServlet(context));
    ws.setInitParameter("transformWsdlLocations", "true"); // Don't use this in production
    ws.addMapping("/services/*");

}

From source file:com.contact.MyWebAppInitializer.java

public void onStartup(ServletContext container) throws ServletException {
    XmlWebApplicationContext appContext = new XmlWebApplicationContext();

    appContext.setConfigLocation("/WEB-INF/spring/appServlet/servlet-context.xml");

    ServletRegistration.Dynamic dispatcher = container.addServlet("appServlet",
            new DispatcherServlet(appContext));

    MultipartConfigElement multipartConfigElement = new MultipartConfigElement(null, 5000000, 5000000, 0);
    dispatcher.setMultipartConfig(multipartConfigElement);

    dispatcher.setLoadOnStartup(1);//from  w  ww  . ja v a  2  s .c  om
    dispatcher.addMapping("/");
}

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

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

From source file:SpringWebAppInitializer.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(ApplicationContextConfig.class);
    ServletRegistration.Dynamic dispactherservlet = sc.addServlet("SpringDispacther",
            new DispatcherServlet(applicationContext));
    dispactherservlet.setLoadOnStartup(1);
    dispactherservlet.addMapping("/");

}

From source file:com.mycompany.testeproject.App.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 ava2 s.  c om
    dispatcher.addMapping("/rest/*");
}

From source file:ip.ip.rest.config.WebAppInitializer.java

public void onStartup(javax.servlet.ServletContext sc) throws javax.servlet.ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(ApplicationConfig.class);
    ctx.setServletContext(sc);//from ww  w.j ava 2s  . c o m
    ServletRegistration.Dynamic dynamic = sc.addServlet("dispatcher", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);
}

From source file:com.mycompany.comerciobici.controlador.InicializadorRest.java

public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(CargadorApplicacion.class);
    ctx.setServletContext(servletContext);
    ServletRegistration.Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);// ww  w.j  ava2  s.c  om
}

From source file:nl.avans.ivh5a1.proftaak.config.ApplicationConfig.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(ApplicationContext.class);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME,
            new DispatcherServlet(rootContext));
    dispatcher.setLoadOnStartup(1);/*from  w w  w .  j  a v  a  2  s.  co  m*/
    dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);

    //        FilterRegistration.Dynamic sitemesh = servletContext.addFilter("sitemesh", new ConfigurableSiteMeshFilter());
    //        EnumSet<DispatcherType> sitemeshDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
    //        sitemesh.addMappingForUrlPatterns(sitemeshDispatcherTypes, true, "*.jsp");

    servletContext.addListener(new ContextLoaderListener(rootContext));
}

From source file:org.brutusin.rpc.RpcWebInitializer.java

private RpcServlet registerRpcServlet(ServletContext ctx) {
    LOGGER.info("Starting HTTP RPC runtime");
    RpcServlet servlet = new RpcServlet();
    ServletRegistration.Dynamic regInfo = ctx.addServlet(RpcServlet.class.getName(), servlet);
    ServletSecurityElement sec = new ServletSecurityElement(new HttpConstraintElement());
    regInfo.setServletSecurity(sec);//from  w ww  .  j av a  2 s . co  m
    regInfo.setLoadOnStartup(1);
    regInfo.addMapping(RpcConfig.getInstance().getPath() + "/http");
    return servlet;
}

From source file:codingsaint.paymentgateway.config.WebInitializer.java

public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(Configurations.class);
    ctx.setServletContext(servletContext);
    Dynamic servlet = servletContext.addServlet("spring", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(LOAD_ON_STARTUP);

}