[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] Embedded jetty filter mapping on multiple path
|
Hi,
On Mon, Jan 12, 2015 at 4:31 PM, paternesi andrea
<andrea.paternesi@xxxxxxxxxx> wrote:
> Good evening,
>
> I am new in this mailing list.
> I am writing because i cannot find any documentation in how to use Jetty
> Embedded Filters.
> First of all i am aware that you can add filters to the
> ServletContextHandler this way:
>
> ServletContextHandler contextHandler = new
> ServletContextHandler(ServletContextHandler.SESSIONS);
> contextHandler.addFilter(MyFilter.class, "/*",
> EnumSet.of(DispatcherType.REQUEST));
>
> this is good and it works without problems.
> But now I need to add multiple paths on the same filter and I was't able
> to accomplish it.
> In web.xml since version 2.5 of servlet specs there is a syntax that
> help us:
>
> <filter-mapping>
> <filter-name>MyFilter</filter-name>
> <url-pattern>/x/*</url-pattern>
> <url-pattern>/y/*</url-pattern>
> </filter-mapping>
>
> In jetty embedded I could not find a way to add both paths "/x/*" and
> "/y/*" to MyFilter.
> Is there a way to do so?
FIlterHolder holder = contextHandler.addFilter(MyFilter.class, "/x/*",
EnumSet.of(DispatcherType.REQUEST));
holder.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST),
true, "/y/*");
--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.