List of usage examples for javax.servlet ServletContext addServlet
public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass);
From source file:dinistiq.web.DinistiqContextLoaderListener.java
/** * Web related dinistiq initialization with parameters taken from the web.xml. * * Looks up relevant packages for scanning and a custom class resolver's implementation class name. Exposes any * bean from the dinistiq scope to the application scope (servlet context) of the web layer including an instance * of dinistiq itself.//from w w w. ja va 2 s . c o m * * @param contextEvent */ @Override public void contextInitialized(ServletContextEvent contextEvent) { // just to check what our log instance looks like LOG.warn("contextInitialized() log: {}", LOG.getClass().getName()); ServletContext context = contextEvent.getServletContext(); Set<String> packages = new HashSet<>(); String packagNameString = context.getInitParameter(DINISTIQ_PACKAGES); if (StringUtils.isNotBlank(packagNameString)) { for (String packageName : packagNameString.split(",")) { packageName = packageName.trim(); packages.add(packageName); } // for } // if String classResolverName = context.getInitParameter(DINISTIQ_CLASSRESOLVER); ClassResolver classResolver = null; if (StringUtils.isNotBlank(classResolverName)) { try { Class<?> forName = Class.forName(classResolverName); Object[] args = new Object[1]; args[0] = packages; classResolver = (ClassResolver) forName.getConstructors()[0].newInstance(args); } catch (Exception e) { LOG.error("contextInitialized() cannot obtain custom class resolver", e); } // try/catch } // if LOG.info("contextInitialized() classResolver: {} :{}", classResolver, classResolverName); classResolver = (classResolver == null) ? new SimpleClassResolver(packages) : classResolver; try { Map<String, Object> externalBeans = new HashMap<>(); externalBeans.put("servletContext", context); Dinistiq dinistiq = new Dinistiq(classResolver, externalBeans); context.setAttribute(DINISTIQ_INSTANCE, dinistiq); for (String name : dinistiq.getAllBeanNames()) { context.setAttribute(name, dinistiq.findBean(Object.class, name)); } // for Collection<RegisterableServlet> servlets = dinistiq.findBeans(RegisterableServlet.class); List<RegisterableServlet> orderedServlets = new ArrayList<>(servlets.size()); orderedServlets.addAll(servlets); Collections.sort(orderedServlets); LOG.debug("contextInitialized() servlets {}", orderedServlets); for (RegisterableServlet servlet : orderedServlets) { ServletRegistration registration = context.addServlet(servlet.getClass().getSimpleName(), servlet); for (String urlPattern : servlet.getUrlPatterns()) { LOG.debug("contextInitialized() * {}", urlPattern); registration.addMapping(urlPattern); } // for } // for } catch (Exception ex) { LOG.error("init()", ex); } // try/catch }
From source file:com.techtrip.dynbl.context.config.WebAppinitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { // Setup Context to Accept Annotated Classes on Input (including plain Spring {@code @Component} // Stereotypes in addition to JSR-330 Compliant Classes using {@code javax.inject} AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); //context.setConfigLocation(APP_CONFIG_LOCATION); context.setConfigLocation(APP_CONFIG_LOCATION); /* //www . j a va2s . c o m * Add a Spring Security Filter using the JEE6 Filter Registration Filter Method from {@code FilterRegistration) that allows filters to be registered * and configured with the specified context */ /* FilterRegistration.Dynamic securityFilter = servletContext.addFilter(ProjectKeyValConsts.SECURITY_FILTER.getKey(), new DelegatingFilterProxy(ProjectKeyValConsts.SECURITY_FILTER.getValue())); securityFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ProjectConsts.BASE_URL_MAPPING_PATTERN.getValue()); // where the filter will be applied */ // Add a Character Encoding Filter that specifies an encoding for mapped requests FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter()); characterEncodingFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ROOT_CONTEXT); // where the filter will be applied characterEncodingFilter.setInitParameter("encoding", "UTF-8"); characterEncodingFilter.setInitParameter("forceEncoding", Boolean.TRUE.toString()); characterEncodingFilter.setAsyncSupported(true); servletContext.addListener(new ContextLoaderListener(context)); servletContext.setInitParameter("defaultHtmlEscape", Boolean.TRUE.toString()); DispatcherServlet servlet = new DispatcherServlet(); // no explicit configuration reference here: everything is configured in the root container for simplicity servlet.setContextConfigLocation(""); /* TMT From JEE 6 API Docs: * Registers the given servlet instance with this ServletContext under the given servletName. * The registered servlet may be further configured via the returned ServletRegistration object. */ ServletRegistration.Dynamic appServlet = servletContext.addServlet(APP_SERVLET, servlet); appServlet.setLoadOnStartup(1); appServlet.setAsyncSupported(true); Set<String> mappingConflicts = appServlet.addMapping("/"); if (!mappingConflicts.isEmpty()) { throw new IllegalStateException(String.format( "The servlet named '%s' cannot be mapped to '/' under Tomcat versions <= 7.0.14", APP_SERVLET)); } // TMT servletContext.addListener(new Log4jConfigListener()); System.out.println("Application inplemented on Spring Version: " + SpringVersion.getVersion()); }
From source file:org.smigo.config.WebAppInitializer.java
@Override protected void beforeSpringSecurityFilterChain(ServletContext servletContext) { super.beforeSpringSecurityFilterChain(servletContext); log.info("Starting servlet context"); log.info("contextName: " + servletContext.getServletContextName()); log.info("contextPath:" + servletContext.getContextPath()); log.info("effectiveMajorVersion:" + servletContext.getEffectiveMajorVersion()); log.info("effectiveMinorVersion:" + servletContext.getEffectiveMinorVersion()); log.info("majorVersion:" + servletContext.getMajorVersion()); log.info("minorVersion:" + servletContext.getMinorVersion()); log.info("serverInfo:" + servletContext.getServerInfo()); // ", virtualServerName:" + servletContext.getVirtualServerName() + log.info("toString:" + servletContext.toString()); for (Enumeration<String> e = servletContext.getAttributeNames(); e.hasMoreElements();) { log.info("Attribute:" + e.nextElement()); }/* w w w.ja v a2s . c om*/ for (Map.Entry<String, String> env : System.getenv().entrySet()) { log.info("System env:" + env.toString()); } for (Map.Entry<Object, Object> prop : System.getProperties().entrySet()) { log.info("System prop:" + prop.toString()); } final String profile = System.getProperty("smigoProfile", EnvironmentProfile.PRODUCTION); log.info("Starting with profile " + profile); WebApplicationContext context = new AnnotationConfigWebApplicationContext() { { register(WebConfiguration.class); setDisplayName("SomeRandomName"); getEnvironment().setActiveProfiles(profile); } }; FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("CharacterEncodingFilter", new CharacterEncodingFilter()); characterEncodingFilter.setInitParameter("encoding", "UTF-8"); characterEncodingFilter.setInitParameter("forceEncoding", "true"); characterEncodingFilter.addMappingForUrlPatterns(null, false, "/*"); servletContext.addListener(new RequestContextListener()); servletContext.addListener(new ContextLoaderListener(context)); //http://stackoverflow.com/questions/4811877/share-session-data-between-2-subdomains // servletContext.getSessionCookieConfig().setDomain(getDomain()); DispatcherServlet dispatcherServlet = new DispatcherServlet(context); dispatcherServlet.setThrowExceptionIfNoHandlerFound(false); servletContext.addServlet("dispatcher", dispatcherServlet).addMapping("/"); }
From source file:fr.univlorraine.mondossierweb.Initializer.java
/** * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.ServletContext) *//* w w w . j a va 2s. c o m*/ @Override public void onStartup(ServletContext servletContext) throws ServletException { addContextParametersToSystemProperties(servletContext); /* Configure les sessions */ Set<SessionTrackingMode> sessionTrackingModes = new HashSet<SessionTrackingMode>(); sessionTrackingModes.add(SessionTrackingMode.COOKIE); servletContext.setSessionTrackingModes(sessionTrackingModes); servletContext.addListener(new HttpSessionListener() { @Override public void sessionCreated(HttpSessionEvent httpSessionEvent) { // sans nouvelle requte, on garde la session active 4 minutes httpSessionEvent.getSession().setMaxInactiveInterval(240); } @Override public void sessionDestroyed(HttpSessionEvent httpSessionEvent) { } }); /* Gestion des sessions dans Atmosphere (Push Vaadin) */ servletContext.addListener(SessionSupport.class); /* Configure Spring */ AnnotationConfigWebApplicationContext springContext = new AnnotationConfigWebApplicationContext(); if (!Boolean.valueOf(servletContext.getInitParameter(Constants.SERVLET_PARAMETER_PRODUCTION_MODE))) { springContext.getEnvironment().setActiveProfiles(DEBUG_PROFILE); } springContext.register(SpringConfig.class); servletContext.addListener(new ContextLoaderListener(springContext)); servletContext.addListener(new RequestContextListener()); /* Filtre Spring Security */ FilterRegistration.Dynamic springSecurityFilterChain = servletContext.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class); springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*"); /* Filtre passant l'utilisateur courant Logback */ FilterRegistration.Dynamic userMdcServletFilter = servletContext.addFilter("userMdcServletFilter", UserMdcServletFilter.class); userMdcServletFilter.addMappingForUrlPatterns(null, false, "/*"); /* Filtre Spring Mobile permettant de dtecter le device */ FilterRegistration.Dynamic springMobileServletFilter = servletContext .addFilter("deviceResolverRequestFilter", DeviceResolverRequestFilter.class); springMobileServletFilter.addMappingForUrlPatterns(null, false, "/*"); /* Servlet Spring-Vaadin */ //ServletRegistration.Dynamic springVaadinServlet = servletContext.addServlet("springVaadin", JMeterServlet.class); //ServletRegistration.Dynamic springVaadinServlet = servletContext.addServlet("springVaadin", SpringVaadinServlet.class); ServletRegistration.Dynamic springVaadinServlet = servletContext.addServlet("springVaadin", fr.univlorraine.mondossierweb.utils.MdwSpringVaadinServlet.class); springVaadinServlet.setLoadOnStartup(1); springVaadinServlet.addMapping("/*"); /* Dfini le bean UI */ //springVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_UI_PROVIDER, "fr.univlorraine.mondossierweb.MdwUIProvider"); /* Utilise les messages Spring pour les messages d'erreur Vaadin (cf. http://vaadin.xpoft.ru/#system_messages) */ springVaadinServlet.setInitParameter("systemMessagesBeanName", "DEFAULT"); /* Dfini la frquence du heartbeat en secondes (cf. https://vaadin.com/book/vaadin7/-/page/application.lifecycle.html#application.lifecycle.ui-expiration) */ springVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL, String.valueOf(30)); /* Configure le Push */ springVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_PUSH_MODE, Boolean.valueOf(servletContext.getInitParameter("enablePush")) ? PushMode.AUTOMATIC.name() : PushMode.DISABLED.name()); /* Active le support des servlet 3 et des requtes asynchrones (cf. https://vaadin.com/wiki/-/wiki/Main/Working+around+push+issues) */ springVaadinServlet.setInitParameter(ApplicationConfig.WEBSOCKET_SUPPORT_SERVLET3, String.valueOf(true)); /* Active le support des requtes asynchrones */ springVaadinServlet.setAsyncSupported(true); /* Ajoute l'interceptor Atmosphere permettant de restaurer le SecurityContext dans le SecurityContextHolder (cf. https://groups.google.com/forum/#!msg/atmosphere-framework/8yyOQALZEP8/ZCf4BHRgh_EJ) */ springVaadinServlet.setInitParameter(ApplicationConfig.ATMOSPHERE_INTERCEPTORS, RecoverSecurityContextAtmosphereInterceptor.class.getName()); /* Spring-Vaadin Touchkit Servlet */ ServletRegistration.Dynamic springTouchkitVaadinServlet = servletContext.addServlet("springTouchkitVaadin", MDWTouchkitServlet.class); //springTouchkitVaadinServlet.setLoadOnStartup(1); springTouchkitVaadinServlet.addMapping("/m/*"); /* Dfini le bean UI */ //springTouchkitVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_UI_PROVIDER, "fr.univlorraine.mondossierweb.MdwTouchkitUIProvider"); /* Utilise les messages Spring pour les messages d'erreur Vaadin (cf. http://vaadin.xpoft.ru/#system_messages) */ springTouchkitVaadinServlet.setInitParameter("systemMessagesBeanName", "DEFAULT"); springTouchkitVaadinServlet.setInitParameter(Constants.PARAMETER_WIDGETSET, "fr.univlorraine.mondossierweb.AppWidgetset"); /* Configure le Push */ springTouchkitVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_PUSH_MODE, PushMode.DISABLED.name()); /* Active le support des servlet 3 et des requtes asynchrones (cf. https://vaadin.com/wiki/-/wiki/Main/Working+around+push+issues) */ springTouchkitVaadinServlet.setInitParameter(ApplicationConfig.WEBSOCKET_SUPPORT_SERVLET3, String.valueOf(true)); /* Active le support des requtes asynchrones */ springTouchkitVaadinServlet.setAsyncSupported(true); /* Ajoute l'interceptor Atmosphere permettant de restaurer le SecurityContext dans le SecurityContextHolder (cf. https://groups.google.com/forum/#!msg/atmosphere-framework/8yyOQALZEP8/ZCf4BHRgh_EJ) */ springTouchkitVaadinServlet.setInitParameter(ApplicationConfig.ATMOSPHERE_INTERCEPTORS, RecoverSecurityContextAtmosphereInterceptor.class.getName()); }
From source file:com.iflytek.edu.cloud.frame.web.RestServiceWebApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { servletContext.setInitParameter("contextConfigLocation", "classpath*:META-INF/spring/*-context.xml"); servletContext.setInitParameter("contextInitializerClasses", ProfileApplicationContextInitializer.class.getName()); servletContext.addListener(new LogBackLoadConfigureListener()); servletContext.addListener(new ContextLoaderListener()); FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter()); EnumSet<DispatcherType> characterEncodingFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);// w w w. j a v a2 s.c o m characterEncodingFilter.setInitParameter("encoding", "UTF-8"); characterEncodingFilter.setInitParameter("forceEncoding", "true"); characterEncodingFilter.addMappingForUrlPatterns(characterEncodingFilterDispatcherTypes, true, "/*"); FilterRegistration.Dynamic openServiceFilter = servletContext.addFilter("openServiceFilter", new DelegatingFilterProxy()); EnumSet<DispatcherType> openServiceFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); openServiceFilter.addMappingForUrlPatterns(openServiceFilterDispatcherTypes, true, "/api"); if (EnvUtil.jdbcEnabled()) { FilterRegistration.Dynamic serviceMetricsFilter = servletContext.addFilter("serviceMetricsFilter", new DelegatingFilterProxy()); EnumSet<DispatcherType> serviceMetricsFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); serviceMetricsFilter.addMappingForUrlPatterns(serviceMetricsFilterDispatcherTypes, true, "/api"); } FilterRegistration.Dynamic CORSFilter = servletContext.addFilter("CORSFilter", new DelegatingFilterProxy()); EnumSet<DispatcherType> CORSFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); CORSFilter.addMappingForUrlPatterns(CORSFilterDispatcherTypes, true, "/api"); if (EnvUtil.oauthEnabled()) { FilterRegistration.Dynamic springSecurityFilterChain = servletContext .addFilter("springSecurityFilterChain", new DelegatingFilterProxyExt()); EnumSet<DispatcherType> springSecurityFilterChainDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); springSecurityFilterChain.addMappingForUrlPatterns(springSecurityFilterChainDispatcherTypes, true, "/api"); } else { logger.info( "?oauth2???META-INF/res/profile.propertiesoauth2 profile"); } ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("rest", new DispatcherServlet()); dispatcherServlet.setLoadOnStartup(1); dispatcherServlet.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName()); dispatcherServlet.setInitParameter("contextConfigLocation", "org.spring.rest"); dispatcherServlet.setMultipartConfig(getMultiPartConfig()); dispatcherServlet.addMapping("/api"); ServletRegistration.Dynamic printProjectVersionServlet = servletContext .addServlet("printProjectVersionServlet", new PrintProjectVersionServlet()); printProjectVersionServlet.setLoadOnStartup(Integer.MAX_VALUE); }
From source file:org.apache.servicecomb.springboot.starter.transport.TestRestServletInitializer.java
@Test public void testOnStartup() throws Exception { Configuration configuration = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource(); String urlPattern = "/rest/*"; configuration.setProperty(ServletConfig.KEY_SERVLET_URL_PATTERN, urlPattern); ServletContext servletContext = mock(ServletContext.class); Dynamic dynamic = mock(Dynamic.class); when(servletContext.addServlet(RestServletInjector.SERVLET_NAME, RestServlet.class)).thenReturn(dynamic); RestServletInitializer restServletInitializer = new RestServletInitializer(); restServletInitializer.setPort(TEST_PORT); restServletInitializer.onStartup(servletContext); verify(dynamic).setAsyncSupported(true); verify(dynamic).addMapping(urlPattern); verify(dynamic).setLoadOnStartup(0); }
From source file:org.apache.servicecomb.springboot.starter.transport.TestRestServletInitializer.java
@Test public void testOnStartupWhenUrlPatternNotSet() throws ServletException { ServletContext servletContext = mock(ServletContext.class); Dynamic dynamic = mock(Dynamic.class); when(servletContext.addServlet(RestServletInjector.SERVLET_NAME, RestServlet.class)).thenReturn(dynamic); RestServletInitializer restServletInitializer = new RestServletInitializer(); restServletInitializer.setPort(TEST_PORT); restServletInitializer.onStartup(servletContext); verify(dynamic).setAsyncSupported(true); verify(dynamic).addMapping(ServletConfig.DEFAULT_URL_PATTERN); verify(dynamic).setLoadOnStartup(0); }
From source file:org.atmosphere.vibe.ProtocolTest.java
@Test public void protocol() throws Exception { final DefaultServer server = new DefaultServer(); server.onsocket(new Action<ServerSocket>() { @Override/*from w ww.j av a 2s. c om*/ public void on(final ServerSocket socket) { socket.on("abort", new VoidAction() { @Override public void on() { socket.close(); } }).on("echo", new Action<Object>() { @Override public void on(Object data) { socket.send("echo", data); } }).on("/reply/inbound", new Action<Reply<Map<String, Object>>>() { @Override public void on(Reply<Map<String, Object>> reply) { Map<String, Object> data = reply.data(); switch ((String) data.get("type")) { case "resolved": reply.resolve(data.get("data")); break; case "rejected": reply.reject(data.get("data")); break; } } }).on("/reply/outbound", new Action<Map<String, Object>>() { @Override public void on(Map<String, Object> data) { switch ((String) data.get("type")) { case "resolved": socket.send("test", data.get("data"), new Action<Object>() { @Override public void on(Object data) { socket.send("done", data); } }); break; case "rejected": socket.send("test", data.get("data"), null, new Action<Object>() { @Override public void on(Object data) { socket.send("done", data); } }); break; } } }); } }); final HttpTransportServer httpTransportServer = new HttpTransportServer().ontransport(server); final WebSocketTransportServer wsTransportServer = new WebSocketTransportServer().ontransport(server); org.eclipse.jetty.server.Server jetty = new org.eclipse.jetty.server.Server(); ServerConnector connector = new ServerConnector(jetty); connector.setPort(8000); jetty.addConnector(connector); ServletContextHandler handler = new ServletContextHandler(); handler.addEventListener(new ServletContextListener() { @Override @SuppressWarnings("serial") public void contextInitialized(ServletContextEvent event) { ServletContext context = event.getServletContext(); // /setup ServletRegistration regSetup = context.addServlet("/setup", new HttpServlet() { @Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { Map<String, String[]> params = req.getParameterMap(); if (params.containsKey("heartbeat")) { server.setHeartbeat(Integer.parseInt(params.get("heartbeat")[0])); } if (params.containsKey("_heartbeat")) { server.set_heartbeat(Integer.parseInt(params.get("_heartbeat")[0])); } } }); regSetup.addMapping("/setup"); // /vibe Servlet servlet = new VibeAtmosphereServlet().onhttp(httpTransportServer) .onwebsocket(wsTransportServer); ServletRegistration.Dynamic reg = context.addServlet(VibeAtmosphereServlet.class.getName(), servlet); reg.setAsyncSupported(true); reg.setInitParameter(ApplicationConfig.DISABLE_ATMOSPHEREINTERCEPTOR, Boolean.TRUE.toString()); reg.addMapping("/vibe"); } @Override public void contextDestroyed(ServletContextEvent sce) { } }); jetty.setHandler(handler); jetty.start(); CommandLine cmdLine = CommandLine.parse("./src/test/resources/node/node") .addArgument("./src/test/resources/runner").addArgument("--vibe.transports") .addArgument("websocket,httpstream,httplongpoll"); DefaultExecutor executor = new DefaultExecutor(); // The exit value of mocha is the number of failed tests. executor.execute(cmdLine); jetty.stop(); }
From source file:org.jumpmind.metl.ui.init.AppInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { Properties properties = loadProperties(); AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext(); applicationContext.scan("org.jumpmind.metl"); MutablePropertySources sources = applicationContext.getEnvironment().getPropertySources(); sources.addLast(new PropertiesPropertySource("passed in properties", properties)); servletContext.addListener(new ContextLoaderListener(applicationContext)); servletContext.addListener(this); servletContext.addListener(new RequestContextListener()); AnnotationConfigWebApplicationContext dispatchContext = new AnnotationConfigWebApplicationContext(); dispatchContext.setParent(applicationContext); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatchContext)); dispatcher.setLoadOnStartup(1);/*from w w w. jav a 2 s. com*/ dispatcher.addMapping("/api/*"); applicationContextRef.set(dispatchContext); ServletRegistration.Dynamic apidocs = servletContext.addServlet("apidocs", DefaultServlet.class); apidocs.addMapping("/api.html", "/doc/*"); ServletRegistration.Dynamic vaadin = servletContext.addServlet("vaadin", AppServlet.class); vaadin.setAsyncSupported(true); vaadin.setInitParameter("org.atmosphere.cpr.asyncSupport", JSR356AsyncSupport.class.getName()); vaadin.setInitParameter("beanName", "appUI"); vaadin.addMapping("/*"); }
From source file:org.lightadmin.core.config.LightAdminWebApplicationInitializer.java
private void registerCusomResourceServlet(final ServletContext servletContext) { final ResourceServlet resourceServlet = new ResourceServlet(); resourceServlet.setAllowedResources("/WEB-INF/admin/**/*.jsp"); resourceServlet.setApplyLastModified(true); resourceServlet.setContentType("text/html"); ServletRegistration.Dynamic customResourceServletRegistration = servletContext .addServlet(LIGHT_ADMIN_CUSTOM_RESOURCE_SERVLET_NAME, resourceServlet); customResourceServletRegistration.setLoadOnStartup(2); customResourceServletRegistration/*from www. j a va 2 s .co m*/ .addMapping(resourceServletMapping(servletContext, LIGHT_ADMIN_CUSTOM_FRAGMENT_SERVLET_URL)); }