All About Filters


You don't have to change a web resource, such as a JSP page, HTML page, or a servlet, to log users who come to that resource, to restrict access to it, to alter the data sent to it, or to alter the data that comes back from it. All you need is a filter.

Creating a new filter isn't hard; it's just a Java class that implements the javax.servlet.Filter interface. You can see all the methods of this interface in Table 6.1.

Table 6.1. The Methods of the javax.servlet.Filter Interface

Method

Does This

void destroy()

Called to indicate that a filter is being destroyed

void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)

Called when control is being passed to the filter

void init(FilterConfig filterConfig)

Called to indicate that a filter is being initialized




    Java After Hours(c) 10 Projects You'll Never Do at Work
    Java After Hours: 10 Projects Youll Never Do at Work
    ISBN: 0672327473
    EAN: 2147483647
    Year: 2006
    Pages: 128

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net