Back in my ASP.NET days, I used URLRewriter.NET to do dynamic URL Rewrites. Basically, it's an HTTPModule that intercepts page requests and rewrites the URLs according to rules that you define, very similar to MOD_REWRITE. However, it also lets you define a "Custom Transform," a class with a single method that does URL translations for you on-the-fly. You can have this method hit the DB, access the Application[] collection, pretty much do anything your heart desires.
Is there any equivalent to this in the J2EE world? I want to be able to rewrite URLs dynamically and delegate this rewriting to some Java code. I do NOT want to just set up a list of static rewrites. Likewise, it needs to do actual URL masking, and NOT 3XX redirects.
If there isn't anything out there that does this, how would I go about building this functionality myself?