use of javax.servlet.FilterRegistration in project webanno by webanno.
the class WebAnnoWebInitializer method onStartup.
@Override
public void onStartup(ServletContext aServletContext) throws ServletException {
// 2) Make username accessible to logging framework
FilterRegistration loggingFilter = aServletContext.addFilter("logging", LoggingFilter.class);
loggingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");
// 5) Make sure we have one JPA session/transaction per request. Closes session at the
// end, without this, changed data may not be automatically saved to the DB.
FilterRegistration openSessionInViewFilter = aServletContext.addFilter("opensessioninview", OpenEntityManagerInViewFilter.class);
openSessionInViewFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");
}
use of javax.servlet.FilterRegistration in project herd by FINRAOS.
the class WarInitializer method initCharacterEncodingFilter.
/**
* Initializes the character encoding filter which provides UTF-8 encoding.
*
* @param servletContext the servlet context.
*/
protected void initCharacterEncodingFilter(ServletContext servletContext) {
// Add a filter that encodes incoming requests and outgoing responses with UTF-8 encoding.
FilterRegistration.Dynamic filterRegistration = servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter());
filterRegistration.setInitParameter("encoding", StandardCharsets.UTF_8.name());
filterRegistration.setInitParameter("forceEncoding", "true");
filterRegistration.addMappingForUrlPatterns(null, true, "/*");
}
use of javax.servlet.FilterRegistration in project mica2 by obiba.
the class WebConfiguration method initGzipFilter.
/**
* Initializes the GZip filter.
*/
private void initGzipFilter(ServletContext servletContext, EnumSet<DispatcherType> disps) {
log.debug("Registering GZip Filter");
FilterRegistration.Dynamic filterRegistration = servletContext.addFilter("gzipFilter", new GzipFilter());
if (filterRegistration == null) {
filterRegistration = (FilterRegistration.Dynamic) servletContext.getFilterRegistration("gzipFilter");
}
filterRegistration.addMappingForUrlPatterns(disps, true, "*.css");
filterRegistration.addMappingForUrlPatterns(disps, true, "*.json");
filterRegistration.addMappingForUrlPatterns(disps, true, "*.html");
filterRegistration.addMappingForUrlPatterns(disps, true, "*.js");
filterRegistration.addMappingForUrlPatterns(disps, true, "/jvm/*");
filterRegistration.addMappingForUrlPatterns(disps, true, WS_ROOT + "/*");
filterRegistration.setAsyncSupported(true);
}
use of javax.servlet.FilterRegistration in project tutorials by eugenp.
the class SpringBootWithServletComponentIntegrationTest method givenServletContext_whenCheckHelloFilterMappings_thenCorrect.
@Test
public void givenServletContext_whenCheckHelloFilterMappings_thenCorrect() {
assertNotNull(servletContext);
FilterRegistration filterRegistration = servletContext.getFilterRegistration("hello filter");
assertNotNull(filterRegistration);
assertTrue(filterRegistration.getServletNameMappings().contains("echo servlet"));
}
use of javax.servlet.FilterRegistration in project jodd by oblac.
the class JoyContextListener method configureServletContext.
/**
* Configures servlet context.
*/
private void configureServletContext(final ServletContext servletContext) {
servletContext.addListener(jodd.servlet.RequestContextListener.class);
if (decoraEnabled) {
final FilterRegistration filter = servletContext.addFilter("decora", jodd.decora.DecoraServletFilter.class);
filter.addMappingForUrlPatterns(null, true, contextPath);
}
final FilterRegistration filter = servletContext.addFilter("madvoc", jodd.madvoc.MadvocServletFilter.class);
filter.addMappingForUrlPatterns(madvocDispatcherTypes, true, contextPath);
}
Aggregations