what are filters in java
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().
off course wew have several mechanisms for that like redirecting page to another page (request dispatcher). all these functionalities can be implemented in controller itself then why we are going for filters
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.