Skip to content

Instantly share code, notes, and snippets.

@mekya
Last active August 4, 2017 13:24
Show Gist options
  • Save mekya/fdc48499bc55cec26e235f140b4f0eb6 to your computer and use it in GitHub Desktop.
Save mekya/fdc48499bc55cec26e235f140b4f0eb6 to your computer and use it in GitHub Desktop.
Http forward filter For S3
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