Image Source Google Images


                       Hello everyone I think everyone celebrate NEW YEAR and Every one welcoming 2013. I hope this year give lot of joeys and what are dreams in your mind comes into true. Now see current post is related to filters. My last post I given some of the Servlet information. Please see all servlet related post once.

                    A filter is a container managed object that is declarative inserted within the request-response cycle of http client and http server. A filter instances acts as an interceptor. It is a preprocessed of the request befre it reaches a servlet and a post processor of the response leaving the servlet. A filter can perform the following.

o   Intercept a servlet’s invocation before a servlet is called.
o   Examine the request before a servlet is called.
o   Modify the request headers and request data.
o   Modify the response headers and response data.
o   Intercept a servlet’s invocation after the servlet is called.

               A filter object implements javax.servlet.Filter.interface. The interface provides 3 life cycle methods.

Public void init(FilterConfig):- Servlet engine calls this method only once after instantiating the filter. Initialization parameters are encapsulated in the FilterConfig object. By calling getInitParameter method in the FilterConfing object we can retrieve them. This method must complete successfully before the filter is asked to day any filtering work.

Public void doFilter(ServletRequest,ServletResponse,FilterChain):- It is called by the container each time a request/ response pair is passed through the chain due to a client request for a resource at the end of the chain. The FilterChain passed into this method allows the filter to pass on the request and response to the next entity in the chain.

Public void destroy():- Called by the servlet engine to indicate to a filter that it is being taken out of service. This method gives the filter an opportunity to clean up any resources that are being held. For example, closing of the database connection.

            Hey common you know my principle why you need to study all the mater right just watch the following video you can understand better way what are the Servlet Filters, right then why late start the following video. Once again HAPPY NEW YEAR 2013. 





Post a Comment

 
Top