Skip to content

Instantly share code, notes, and snippets.

@chkal
Created February 17, 2018 08:46
Show Gist options
  • Save chkal/38d385a290e6e906fa8ede1cfc08d1ab to your computer and use it in GitHub Desktop.
Save chkal/38d385a290e6e906fa8ede1cfc08d1ab to your computer and use it in GitHub Desktop.
NoopServletFilter.java
@WebFilter("/*")
public class NoopServletFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// empty
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
if (request.getRequestURI().matches("^.*/rfRes/bla.css$")) {
response.setStatus(204);
response.flushBuffer();
} else {
filterChain.doFilter(request, response);
}
}
@Override
public void destroy() {
// empty
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment