Explain Life cycle of Servlet Filter.

Answer Posted / sunita

filters life cycle:
The life cycle of a filter is managed by a container. Every
filter must implement the Filter interface. The life cycle
of a filter consists of implementing the following methods:

1. init(): This method is called only once after
instantiation to perform any initialization task.

2. doFilter(): This method is called after the init()
method. It takes three arguments, namely a ServletRequest, a
ServletResponse, and a FilterChain. It is called each time a
filter needs to perform any function. This method performs
the actual work of a filter, either modifying the request or
the response.

3. destroy(): This method is used to perform any cleanup
operation before the container removes a filter instance.

Is This Answer Correct ?    36 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What classes of exceptions may be caught by a catch clause?

754


Explain about thread synchronization inside a monitor?

2224


What is the form of storage space in java?

1950


What is a class loader? What are the different class loaders used by jvm?

789


What is threadfactory?

838


difference between  ejb,struts,hibernate,spring and jsp

2555


What class is the top of the awt event hierarchy?

807


What is the difference between session and entity beans?

786


What is clustering? What are the different algorithms used for clustering?

781


Java is fully object oriented languages or not?

732


Are we allowed to change the transaction isolation property in middle of a transaction?

760


Explain what is synchronization?

815


Is the infobus client side only?

847


What is the difference between the session.update() method and the session.lock() method?

733


How can I avoid validating a form before data is entered?

724