Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes @WebFilter issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "@WebFilter issue" Watch "@WebFilter issue" New topic

@WebFilter issue

Yasir Karim

Joined: Jul 21, 2011
Posts: 17

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:
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {

I see the truth in the code.
Roel De Nijs

Joined: Jul 19, 2004
Posts: 6372

The Filter interface declares a doFilter-method with 3 parameters, so it's likely the code example is not a valid override.

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
Dieter Quickfend

Joined: Aug 06, 2010
Posts: 543

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.

Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
jQuery in Action, 2nd edition
subject: @WebFilter issue