Explain Life cycle of Servlet Filter.

Answers were Sorted based on User's Feedback



Explain Life cycle of Servlet Filter...

Answer / 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

Explain Life cycle of Servlet Filter...

Answer / surajkumar.java

A java class which implements javax.servlet.Filter is
configured as filter in web.xml file.
The web container calls the init method to initialize filter
by passing javax.servlet.FilterConfig object to retrieve the
filter’s init parameters.
The doFilter method of Filter class performs the actual
processing like authentication, data format conversion and
page redirect to other page and catching etc. The doFilter
method passes the request and response object of the current
request and the filter chain object to invoke next filter in
the chain.
Web container calls the destroy() method to take the filter
out of service.

Is This Answer Correct ?    29 Yes 7 No

Post New Answer

More Advanced Java Interview Questions

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

0 Answers  


What happens when we invoke a thread?s interrupt method while it is in sleeping or waiting condition?

1 Answers  


Which Taglibraury you used in your project? plz send me ans....which we r using generally

2 Answers  


What is the diffrence between a local-tx-datasource and a xa-datasource?

0 Answers  


What is Remote Interface?

1 Answers  






What are the services in RMI ?

0 Answers  


a US company has filed my H1B visa ,, and i got selected in random number process.I wanna ask Could they ask regarding my languages(java,c++) or there will b just general questions?? And wat kind of questions will they ask in embassy interview??

2 Answers  


the same information whether it will connect to the database or it will be used previous information?

0 Answers  


wahts is mean by dynavalidatorform in struts/

0 Answers   SolutionNET,


Difference between hashmap and hashtable?

0 Answers  


If I wanted to use a solarisui for just a jtabbedpane, and the metal ui for everything else, how would I do that?

0 Answers  


How to determine SGA site?

0 Answers   Wipro,


Categories