views:

330

answers:

2

I want to write my own version of url rewriting for my app, but I don't know how to change the url of the incoming request in the filter.

I tried just forwarding to the rewritten url, but that makes it so all other filters in the chain are not called.

A: 

but that makes it so all other filters in the chain are not called.

Just reconfigure the other filters to listen on the new url-pattern.

BalusC
the other filter i speak of is mapped to /*. But I did find out that I can add a <dispatcher>FORWARD</dispatcher> to the filter mapping and that makes it get called.
Kyle
And that also, yes. Good you found it yourself.
BalusC
+1  A: 

The right way to do it is to create a subclass of HttpServletRequestWrapper, override its getRequestURI() and other methods to return the new URL, and wrap the request with it. So you don't have to change the other filter mappings.

axtavt