Home  >  Article  >  Java  >  What does java filter do?

What does java filter do?

(*-*)浩
(*-*)浩Original
2019-05-22 16:39:2417043browse

The Java filter is a filter between the client and the server resource file. Before accessing the resource file, the request can be modified and judged through a series of filters, and the requests that do not comply with the rules can be modified. The request is intercepted or modified midway; the response can also be filtered, intercepted or modified.

What does java filter do?

Filters are also a commonly used part in Java and are used to restrict certain things. Let’s take a look at them below.

Filter is a filter between the client and the server resource file. Before accessing the resource file, the request is modified and judged through a series of filters. Requests that do not comply with the rules are intercepted or modified midway. Responses can also be filtered, intercepted or modified.

What does java filter do?As shown in the figure, the request sent by the browser is first submitted to the first filter for filtering. If it meets the rules, it is released and submitted to the next filter in the filter chain for filtering. The order of filters in the chain is related to the order in which they are configured in web.xml. The one configured first is located at the front end of the chain. When the request passes all the filters in the chain, the resource file can be accessed. If it cannot pass, it may be processed in one of the intermediate filters.

In the doFilter() method, the code before chain.doFilter() is generally the filtering operation performed on the request, and the code after chain.doFilter is generally the operation performed on the response. The execution sequence of the filter chain code is as follows:

What does java filter do?

Filters are generally used for login permission verification, resource access permission control, sensitive word filtering, character encoding conversion and other operations to facilitate code Reuse, there is no need to perform corresponding operations in each servlet.

The above is the detailed content of What does java filter do?. 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

Related articles

See more