Home  >  Article  >  Java  >  what is filter in java

what is filter in java

little bottle
little bottleOriginal
2019-05-24 14:44:4712353browse

The filter in java refers to a method that plays a filtering role in java, which can reduce the redundancy of the code. Classification of filters: 1. Filters authorized by users; 2. Filters used to filter and judge logs; 3. Filters responsible for decoding recording tracks.

what is filter in java

java filter, as the name suggests, is a method that plays a filtering role in java.

(Video tutorial recommendation: java course)

You can intercept a request for logical judgment before it reaches the servlet. It then decides whether to release the requested servlet.

You can also intercept the result for logical judgment before a response reaches the client, and then decide whether to allow it to be returned to the client.

Filter (filter) has the following types (functions):

1. Filter authorized by the user: filter is responsible for determining whether the user Have permission to request this page.

2. Give filter to filter and judge the log: Intercept all requests of a user on this website.

3, Record the filter responsible for decoding the track: Specifies the decoding method for processing this request.

Finally, it should be noted that a filter can be added to multiple servlet controllers. Of course, multiple filters can also be added to a servlet controller.

It can also be seen from this that weuse filter to often process some common operations.

For example: determine user permissions, decode this request, etc.

For example, some pages in our web application require users to log in before they can access them. In the past, we added judgment control to each servlet page, resulting in code redundancy.

With filter, we can define a filter that implements filter, so that such a filter can be added to all pages that need to determine whether to log in, which can greatly reduce the redundancy of the code.

Related recommendations: java introductory tutorial

The above is the detailed content of what is filter in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn