Guest User

Untitled

a guest
May 20th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public class CancellableRequestFilter implements Filter {
  2. public void init(FilterConfig filterConfig) throws ServletException {
  3. }
  4.  
  5. public void destroy() {
  6. }
  7.  
  8. public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  9. try {
  10. chain.doFilter(request, response);
  11. } catch (ServletRequestAbortException e) {
  12. //TODO: Maybe flush/close response here.
  13. }
  14. }
  15.  
  16. public static void endRequest() {
  17. throw new ServletRequestAbortException();
  18. }
  19.  
  20. public static class ServletRequestAbortException extends RuntimeException {
  21. }
  22. }
  23.  
  24. <% com.your.pkg.CancellableRequestFilter.endRequest(); %>
Add Comment
Please, Sign In to add comment