Good day!
I made a filter servlet and I am trying to not include the css and js. So I wrote this code:
if (url.equals("/login.jsp") || url.equals("/login") ||url.equals("/AddApplicantServlet") ||url.equals("css/*") || url.equals("js/*") ||url.equals("/index.jsp") {
chain.doFilter(request, response);
} else {
....
}
My XML is
<filter>
<filter-name>ServletFilter</filter-name>
<filter-class>filter.ServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ServletFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
But on the above code.. the url.equals("css/*") and url.equals("js/*") doesnt work… It seems that using wildcard on the URLs are not possible.
Is there any other way to code this?
The
String.equalsmethod checks for strict equality.You should call
startsWith.You can also call
matchesto test it against a regex.