peony2012 / urlrewritefilter

Automatically exported from code.google.com/p/urlrewritefilter
Other
0 stars 0 forks source link

Enhancement: add a parameter to allow dispathing to servlets #95

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

When I use something like this to dispatch directly to servlets:

<rule>
<from>^/static/(.*)$</from>
<run class="bla.bla.StaticServlet" method="doGet(HttpServletRequest, 
HttpServletResponse)" />
</rule>

It will then after this method invocation ALSO enter the rest of the filter 
chain and execute the default servlet. This gives an exception since output is 
already set on the response by StaticServlet.

Enhancement:

Add some parameter that will prevent this type of dual exection. Here is an 
example that I use to prevent the call further down the filter when the 
response is already filled by a method invocation:

public class UrlRewriteFilterWrapper extends 
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter {

    // Override doFilter in UrlRewriteFilter
    @Override
    public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
                throws IOException, ServletException {

        FilterChain modifiedChain = new FilterChain() {
            @Override
            public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {

                if (!response.isCommitted()) {
                    chain.doFilter(request, response);
                }
            }
        };
        super.doFilter(request, response, modifiedChain);

    }
}

Original issue reported on code.google.com by mike...@gmail.com on 12 Oct 2011 at 4:11

GoogleCodeExporter commented 9 years ago

Original comment by p...@tuckey.org on 25 Jun 2012 at 2:37