tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: Can Filter-mappings be defined using regular expressions?
Date Tue, 03 Dec 2002 23:28:52 GMT


On Tue, 3 Dec 2002, Stephen Riek wrote:

> Date: Tue, 3 Dec 2002 23:12:47 +0000 (GMT)
> From: Stephen Riek <stephenriek@yahoo.co.uk>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> Subject: Can Filter-mappings be defined using regular expressions?
>
>
>  There's got to be a better way of writing Filter-mapping than the following, where I
want to allow any URL that begins either with:
> a) /Products/*  or
> b) /<2 characters>/Products/*
>
> ---------------------->8--------------------------
>
> <filter-mapping>
>   <filter-name>ProductsFilter</filter-name>
>   <url-pattern>/Products/*</url-pattern>
>  </filter-mapping>
>
> <filter-mapping>
>   <filter-name>ProductsFilter</filter-name>
>   <url-pattern>/en/Products/*</url-pattern>
>  </filter-mapping>
>
>  <filter-mapping>
>   <filter-name>ProductsFilter</filter-name>
>   <url-pattern>/de/Products/*</url-pattern>
>  </filter-mapping>
>
>  <filter-mapping>
>   <filter-name>ProductsFilter</filter-name>
>   <url-pattern>/fr/Products/*</url-pattern>
>  </filter-mapping>
>
>  <filter-mapping>
>   <filter-name>ProductsFilter</filter-name>
>   <url-pattern>/es/Products/*</url-pattern>
>  </filter-mapping>
>
> ---------------------->8--------------------------
>
> Using */Products/* doesn't necessarily do it (and I think wouldn't work anyway) since
it would also collect match /SomeFolder/Another/Products which would be incorrect.
>
> I don't mind using the above excep that it gets messy with multiple
> filters, and I was wondering if it could be more efficient for Tomcat
> written some other way.
>

An alternative strategy would be to map your filter to "/*" (so it
receives all requests) and then programmatically check the request URI in
the filter to decide whether or not to perform the redirection action.
You could use things like regular expressions, or whatever you wanted, to
make that sort of comparison.

> Thanks,
>
> Stephen.
>

Craig


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message