Skip to content

Commit

Permalink
include filter to disable URL rewriting (ex: jsessionid stuff), which…
Browse files Browse the repository at this point in the history
… isn't something we're going to support in Able
  • Loading branch information
lightbody committed Nov 22, 2011
1 parent 6d9acb1 commit a933025
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
@@ -0,0 +1,40 @@
package net.lightbody.able.jetty;

import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import java.io.IOException;

public class DisableURLRewritingFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException {
}

public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
filterChain.doFilter(servletRequest, new NoURLRewriteServletResponseWrapper(servletResponse));
}

public void destroy() {
}

private static class NoURLRewriteServletResponseWrapper extends HttpServletResponseWrapper {
public NoURLRewriteServletResponseWrapper(ServletResponse servletResponse) {
super((HttpServletResponse) servletResponse);
}

public String encodeRedirectUrl(String url) {
return url;
}

public String encodeRedirectURL(String url) {
return url;
}

public String encodeUrl(String url) {
return url;
}

public String encodeURL(String url) {
return url;
}
}
}
Expand Up @@ -34,6 +34,7 @@ public EmbeddedJettyWebAppProvider(@Named("port") int port, @AnchorClass Class a
context.setContextPath("/");
context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");

context.addFilter(DisableURLRewritingFilter.class, "/*", 0);
context.addFilter(GuiceFilter.class, "/*", 0);
context.addServlet(DefaultServlet.class, "/");

Expand Down

0 comments on commit a933025

Please sign in to comment.