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 is the difference between the string and stringbuffer classes?

543


How to pass parameters in RMI?

1688


Difference between swing and awt?

601


What is the difference between static and non-static with examples?

1358


Explain about thread synchronization inside a monitor?

1994






what is an isolation level?

2212


Why use a datasource when you can directly specify a connection details? (in a J2EE application)

3447


What is the RMI and Socket?

623


Whats new with the stop(), suspend() and resume() methods in jdk 1.2?

581


What is Remote Server?

1682


What is TL and its use?

1989


What is prototype?

607


Write a singleton program?

568


How are commas used in the intialization and iteration parts of a for statement?

581


What is glasgow?

582