Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public class SCI implements ServletContainerInitializer {
  2. @Override
  3. public void onStartup(Set<Class<?>> arg0, ServletContext arg1)
  4. throws ServletException {
  5. arg1.addFilter("myFilter", MyFilter.class).addMappingForUrlPatterns(null, false, "/*");
  6. }
  7. }
  8.  
  9. public static class MyFilter implements Filter {
  10.  
  11. @Override
  12. public void destroy() { }
  13.  
  14. @Override
  15. public void doFilter(ServletRequest arg0, ServletResponse arg1,
  16. FilterChain arg2) throws IOException, ServletException {
  17. if (arg1 instanceof HttpServletResponse) {
  18. ((HttpServletResponse) arg1).addHeader("Test", "Test");
  19. }
  20. arg2.doFilter(arg0, arg1);
  21. }
  22.  
  23. @Override
  24. public void init(FilterConfig arg0) throws ServletException { }
  25. }
  26.  
  27. test.SCI
  28.  
  29. <featureManager>
  30. <feature>bells-1.0</feature>
  31. </featureManager>
  32.  
  33. <library id="init">
  34. <file name="path/to/jar"/>
  35. </library>
  36.  
  37. <bell libraryRef="init"/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement