Oleksandr Papchenko
Oleksandr Papchenko

Reputation: 2211

How i can skip filter for static content?

In my web-app i have front filter that is acting like router. It just routes to proper controller and action according to request url. To do that i added following in my WEB.xml

<filter>
    <filter-name>FrontFilter</filter-name>
    <filter-class>service.FrontFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>FrontFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

But the problem is that if i want just get static html page. My filter is invoked too and starts to find controller and action. And of course it fails. I tried to place all my static content to /public folder and do in filter something like that:

if (reqURI.contains("/public/")) {
           chain.doFilter(request, response);
}

but with no success. So, how i can skip filter for static content like images and just html? I will highly appreciate your any response.

Upvotes: 3

Views: 1652

Answers (1)

Suresh Atta
Suresh Atta

Reputation: 121998

In your case to skip the filter for html file urls, Try

if (reqURI.endsWith(".html")) {
    chain.doFilter(request, response); 
} 

Upvotes: 3

Related Questions