What is Servlet Filter and how does it work?

Ask a question

What is Servlet Filter and how does it work?

<<Previous   Next>>

Java - What is Servlet Filter and how does it work? - March 16, 2010 at 15:05 PM by Vidya Sagar 

What is Servlet Filter and how does it work?

Filters are powerful tools in servlet environment. Filters add certain functionality to the servlets apart from processing request and response paradigm of servlet processing. Filters manipulate the request and response in a web application, and they can be applied to any resources like HTML, graphics, a JSP page which are served by the servlet engine. Authentication of data, format conversion of data and redirecting the page to another page are certain useful functions of filters.

A filter is configured in a web.xml file. The class using the filters should extend javax.servlet.Filter. Every request in a web application, the servlet container decides the filters to apply and adds them to the filter chain, in the order they appear in web.xml file. A filter also has life cycle mechanisms init(),doFilter() and destroy(). 

<<Previous   Next>>

Test your Java skills

Java part 1 (39 questions)
Java part 2 (40 questions)
EJB (20 questions)
JDBC (20 questions)
Applet (20 questions)
Struts (21 questions)
Servlets (20 questions)
Java web services (20 questions)

What is the difference between preemptive scheduling and time slicing?

Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. It also executes, until a higher priority task enters..................

What is DatabaseMetaData?

DatabaseMetaData provides comprehensive information about the database. This interface is implemented by the driver vendors to allow the user to obtain information about the tables of a relational database as a part of JDBC application..................

What is Java Isolates and why do we need it?

Java Isolates is an API. It provides a mechanism to manage Java application life cycles which are isolated from each other. They can potentially share the underlying implementation resources............ .

Write your comment - Share Knowledge and Experience

Discussion Board
Another point

Another point about filters is that they create a chain when the same url pattern is used for multiple filters. We need to call filter.doChain method
Java EE filter

About Java EE Filters 01-16-2013 12:01 PM



Interview questions
Home | Login | About us | Sitemap | Contact us