Last active
August 4, 2017 13:24
-
-
Save mekya/fdc48499bc55cec26e235f140b4f0eb6 to your computer and use it in GitHub Desktop.
Http forward filter For S3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HttpForwardFilter implements javax.servlet.Filter { | |
@Override | |
public void destroy() { | |
} | |
@Override | |
public void doFilter(ServletRequest request, ServletResponse response, | |
FilterChain chain) throws IOException, ServletException { | |
String requestURI = ((HttpServletRequest)request).getRequestURI(); | |
File f = new File("webapps/"+ requestURI); | |
if (!f.exists()) | |
{ | |
String redirectUri = Application.STORAGE_FORWARD_URL + requestURI; | |
HttpServletResponse httpResponse = (HttpServletResponse) response; | |
httpResponse.sendRedirect(redirectUri); | |
return; | |
} | |
chain.doFilter(request, response); | |
} | |
@Override | |
public void init(FilterConfig arg0) throws ServletException { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment