In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to achieve web filter, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Filter
Overview
Technically, a filter is an intermediate component that intercepts messages between source and destination data and filters the data passed between them. It acts like a guard, preventing unwanted messages from passing from one point to another.
For Web applications, the filter is the Web component that resides on the Web server, which filters requests and responses passed from the client to the server. When the Web container receives a request for a resource, it determines whether a filter is associated with the resource. If so, give it to the filter, which can change the contents of the request, or reset the request header, and then pass the request to the target resource. It can also modify the response sent by the server.
From the above process, we can see that both the client and the target resources are transparent, and they do not need to know about the existence of the filter.
In this process, you can also set up multiple filters to form a chain to deal with them accordingly.
Application:
1. Authentication filtering: unified authentication of user requests
two。 Login and audit filtering: record and audit user access requests.
3. Image conversion filtering: converting image format
4. Data compression filtering: compress the data generated by the user, thereby reducing the amount of transmission
5. Encryption filtering: encrypting and decrypting requests and responses
6. Token filtering
7. Resource access trigger event filtering
8.XSLT filtering
9.MIME-type filtering
Code:
The filter must implement the interface Filter
There are three ways to implement
1.init ()-initialize
2.doFilter ()-Filterin
3.destroy ()-destroy
Note: the javax.servlet package includes
ServletRequest 、 ServletResponse 、 ServletExcption 、 FilterConfig 、 Filter 、 FilterChain
The javax.io package includes:
PrinterWriter 、 IOExcption
Deployment of Filter
Its deployment is similar to that of servlet eg:
Hello com.lovo.HelleWorld Hello / filter/*
Filter API:
Three interfaces implemented by the container:
1.javax.servlet.Filter
2.javax.serlvet.Filter.Chain
3.javax.servlet.FilterConfig-like servletConfig in servlet, it mainly provides filter initialization parameters.
Four wrapper classes implemented by the container:
1.javax.servlet.ServletRequestWrapper
2.javax.servlet.Servletresponsewrapper
3.javax.servlet.HttpServletRequestWrapper
4.javax.servlet.HttpServletResponseWrapper
Web filters prevent WVS scanning and injection, cross-site, etc.
The above is all the content of the article "how to implement web filter". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.