Example usage for javax.servlet ServletRegistration setInitParameter

List of usage examples for javax.servlet ServletRegistration setInitParameter

Introduction

In this page you can find the example usage for javax.servlet ServletRegistration setInitParameter.

Prototype

public boolean setInitParameter(String name, String value);

Source Link

Document

Sets the initialization parameter with the given name and value on the Servlet or Filter that is represented by this Registration.

Usage

From source file:com.dm.platform.listener.base.MyServletContextListener.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    System.out.println("MyServletContextListener");
    ServletContext sc = sce.getServletContext();

    ServletRegistration sr = sc.addServlet("spring", DispatcherServlet.class);
    sr.setInitParameter("contextConfigLocation", "/WEB-INF/dispatcher-servlet.xml");
    sr.addMapping("/spring/*");

    FilterRegistration fr = sc.addFilter(DynamicRegistFilter.class.getSimpleName(), DynamicRegistFilter.class);
    fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/platform/*");
    //          fr = sc.addFilter(DelegatingFilterProxy.class.getSimpleName(), DelegatingFilterProxy.class);
    //        fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/platform/*");

    sc.addListener(new ContextLoaderListener());
}

From source file:com.dm.platform.listener.PlatformServletContextListener.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    System.out.println("contextInitialized");

    ServletContext sc = sce.getServletContext();
    sc.setInitParameter("contextConfigLocation", "/WEB-INF/applicationContext.xml");
    //    sc.addListener(ContextLoaderListener.class);
    FilterRegistration fr = sc.addFilter(DelegatingFilterProxy.class.getSimpleName(),
            DelegatingFilterProxy.class);
    fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/spring/*");

    ServletRegistration sr = sc.addServlet("spring", DispatcherServlet.class);
    sr.setInitParameter("contextConfigLocation",
            "/WEB-INF/dispatcher-servlet.xml /WEB-INF/platform-security.xml");
    sr.addMapping("/spring/*");

    fr = sc.addFilter(DynamicRegistFilter.class.getSimpleName(), DynamicRegistFilter.class);
    fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/platform/*");

}

From source file:org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration.java

@Override
public void setServletContext(ServletContext servletContext) {
    String servletRegistrationName = getServletRegistrationName();
    ServletRegistration registration = servletContext.getServletRegistration(servletRegistrationName);
    if (registration != null) {
        if (logger.isInfoEnabled()) {
            logger.info(/* w  ww  .  j a  v  a2  s. c  o m*/
                    "Configuring existing registration for Jersey servlet '" + servletRegistrationName + "'");
        }
        registration.setInitParameters(this.jersey.getInit());
        registration.setInitParameter(CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE,
                Boolean.TRUE.toString());
    }
}