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.
The URL Rewrite module lets you translate search engine-friendly URLs into a format that your application currently uses. Also, it lets you create redirect rules that can be used to redirect search engine crawlers to clean URLs.
Url rewriting is a process of appending or modifying any url structure while loading a page. The request made by client is always a new request and the server can not identify whether the current request is send by a new client or the previous same client.
A Java Web Filter for any compliant web application servers (such as Tomcat, JBoss, Jetty or Resin), which allows you to rewrite URLs before they get to your code.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With