tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Bremford" <>
Subject mod_rewrite Interceptor - feedback please!!
Date Tue, 12 Sep 2000 11:55:25 GMT
Hi all

I'm trying to write an interceptor to handle URI's rewritten by Apache's
mod_rewrite, but this is the first time I've opened Tomcat up - feedback on
my approach would be valuable.

The route I've taken is:

1. Read the rewritten URI in the Ajp12Connection, store it as a note on the
2. Create a new interceptor (tentatively called ApacheInterceptor) which
reads the note and does something with it.

What I'm pondering at the moment is the best way to instruct Tomcat to use
the correct file but still have getRequestURI return the correct value. Here
are the options so far:

1. Set the ServletPath, leave the URI untouched.
   * Pros: Works perfectly (this is what JServ did), very low impact (one
line in  the Interceptor).
   * Cons: Seems to violate the Servlet 2.2 Spec. (Can someone who knows the
spec better than I confirm this).

2. Treat the redirected URI as a jsp:include by setting
   * Pros: Equally low impact, doesn't violate the spec like #1.
   * Cons: This works for JSP's, but will it work for servlets? The 2.2 spec
section 8.3 also limits what headers I can set in an include, which rules
this one out I believe.

3. Modify the HttpServletRequestFacade, so getRequestURI and related methods
return the rewritten URI (if it exists).
   * Pros & Cons: Don't know, but it looks good. My current favourite.

I'm swimming a bit out of my depth here - help! Any tips, thoughts or
whatever would be appreciated.

Cheers.... Mike

PS. In my efforts to work out what the hell is going on, I've knocked up a
quick diagram which may be useful to others working on Tomcat source for the
first time (assuming it's correct that is - can someone check it for errors?
It's at

View raw message