Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 633
Kyle Avatar asked Jan 26 '10 04:01

Kyle


People also ask

What does rewrite URL do?

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.

What is URL rewriting in Java?

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.

What is URLrewritefilter?

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.


1 Answers

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.

like image 130
axtavt Avatar answered Oct 02 '22 15:10

axtavt