Reputation: 9697
I am using a some filter mapping for my project . The following filter pattens hit the filter
<filter-mapping>
<filter-name>wygUserCheckFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>wygUserCheckFilter</filter-name>
<url-pattern>/myProject/MyDisplay.jsp</url-pattern>
</filter-mapping>
But the one below doesn't hit the filter
<filter-mapping>
<filter-name>wygUserCheckFilter</filter-name>
<url-pattern>/myProject/*.jsp</url-pattern>
</filter-mapping>
Why is this so ?
Upvotes: 0
Views: 335
Reputation: 2093
From Servlet 2.5 spec:
SRV.11.2
Specification of Mappings
In the Web application deployment descriptor, the following syntax is used to define mappings:
- A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping.
- A string beginning with a ‘*.’ prefix is used as an extension mapping.
- A string containing only the ’/’ character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null.
- All other strings are used for exact matches only.
Upvotes: 2
Reputation: 42114
Because * in the middle of the pattern matches only to the * character. Only matching url for /myProject/*.jsp-pattern is exactly same string. * does have special meaning only in the following cases (Servlet 2.4 Specification):
- A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping.
- A string beginning with a ‘*.’ prefix is used as an extension mapping.
- A string containing only the ’/’ character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the con- text path and the path info is null.
- All other strings are used for exact matches only.
Upvotes: 3