301 permanent redirect with Tomcat

Whenever I set up a new site, I want to make sure that example.com points to www.example.com. This is basic SEO – check out this link for a quick explanation. I know that this is trivial to do in Apache, but for the sake of simplicity, I wanted to use Tomcat only as my web server. This often happens in essay services, so I decided to write my capstone project for students with instructions and concepts related to SEO.

After much searching around, it became clear that (1) Tomcat can’t do this, and (2) I’m not the only person with this problem. The solution is a Java servlet filter called URLRewriteFilter. It does the job perfectly, but it took ...

more ...