JBoss 7 (even JBoss 6 already) supports Java EE 6, which in turn covers Servlet 3.0. Perhaps your web.xml incorrectly declared compatible with Servlet 2.5, because of which @WebFilter does not work at all. Make sure the root declaration of your web.xml been declared appropriate for servlet 3.0 as follows:
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
Then you can just use @WebFilter :
@WebFilter("/api/*") public class FooFilter implements Filter {
The examples you showed there are part of JAX-RS, which is another API (RESTful webservice API) built on top of Servlets. To learn more about JAX-RS, a Jersey user guide may be helpful.
See also:
Balusc
source share