Java - How does the Tuckee URL Rewrite filter change the url of the request?

jakarta-ee, java, servlet-filters

Solution

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.

Problem

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.

Original source