Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@WebFilter issue

 
Yasir Karim
Greenhorn
Posts: 17
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Final Servlet 3.0 specs

Section 8.1.2

CODE EXAMPLE 8-3 @WebFilter annotation example @WebFilter(“/foo”)
public class MyFilter implements Filter {
public void doFilter(HttpServletRequest req, HttpServletResponse res)
{
...
} }


Comment: Don't you think the method signature is wrong?
It should be:
@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
...
 
Roel De Nijs
Sheriff
Posts: 10220
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Filter interface declares a doFilter-method with 3 parameters, so it's likely the code example is not a valid override.
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also, Filter interface declares three methods, not one.

- public void init(FilterConfig) throws ServletException
- public void doFilter(ServletRequest, ServletResponse, FilterChain) throws IOException, ServletException
- public void destroy()

You must implement these three methods to have a valid implementation of Filter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic