On Fri, 22 Nov 2002, Stephen Riek wrote:
> Date: Fri, 22 Nov 2002 09:40:11 +0000 (GMT) > From: Stephen Riek <[EMAIL PROTECTED]> > Reply-To: Tomcat Users List <[EMAIL PROTECTED]> > To: Tomcat Users List <[EMAIL PROTECTED]> > Subject: can a Tomcat Filter rewrite the URL ? > > > I'd like for a request to "<webapp>/en/Folder/File" to be mapped to > "<webapp>/Folder/File" but with a parameter 'lang' set to 'en'. > Likewise, a request to "<webapp>/fr/Folder/File" to be mapped to > "<webapp>/Folder/File" but with a parameter 'lang' set to 'fr'. Is this > possible with Filters? One approach would be to map your Filter to URL pattern "/*" so that it sees every request. On each request, you would look at the request URI to see if this is one that should be remapped. If not, just call chain.doFilter() in the usual way. If you see that this one should be overwritten, you'll want to create a custom HttpServletRequestWrapper class that overrides all the path related methods (getRequestURI(), getServletPath(), getPathInfo(), and so on) to return the adjusted values. Finally, grab a RequestDispatcher to the modified path (such as "/Folder/File" and call its forward() method, instead of calling chain.doFilter(). > If not, is there any way to accomplish this within Tomcat so that it works for any >number of directories and subdirectories. The reason I want to do this is to avoid >copying/pasting an entire sitemap to support a second language - I know that some >people create a site in English then copy/paste the directory tree to support a >second language but this is not scalable and difficult to maintain. > Other mechanisms I've looked at are Apache rewrite rules but they're very >complicated. > Any and all help much appreciated. Thank you. > Stephen. > Craig -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
