Class SlashFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    @Component
    public class SlashFilter
    extends java.lang.Object
    implements javax.servlet.Filter
    A simple filter that wraps HttpServletRequest to replace any incoming requests with two or more slashes with a single slash. This is to band-aid a bug that we encountered where multiple slashes in a URL would cause our REST controllers to build links for the response that had duplicated sections, resulting in invalid links.
    • Constructor Summary

      Constructors 
      Constructor Description
      SlashFilter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()
      void doFilter​(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
      void init​(javax.servlet.FilterConfig filterConfig)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SlashFilter

        public SlashFilter()
    • Method Detail

      • init

        public void init​(javax.servlet.FilterConfig filterConfig)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • doFilter

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws java.io.IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        java.io.IOException
        javax.servlet.ServletException
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter