*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "@WebFilter issue" Watch "@WebFilter issue" New topic
Author

@WebFilter issue

Yasir Karim
Greenhorn

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


I see the truth in the code.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5126
    
  12

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
http://www.javaroe.be/
Dieter Quickfend
Bartender

Joined: Aug 06, 2010
Posts: 503
    
    4

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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @WebFilter issue
 
Similar Threads
Java Filter and uncaughtExceptions
How specify filter chain with @WebFilter
Why no HttpServletReq on doFilter?
WebFilter Annotation and servletNames attribute
Why is ServletFilter.doFilter() not getting invoked?