官术网_书友最值得收藏!

Implementing the intercepting filter pattern using Java EE 8

To implement this pattern with the best practices of Java EE 8, we will use the servlet filter from the Java Servlet specification. With the servlet filter, we can create an ordered request interceptor to treat the requests and responses. These interceptors are mapped by the URL pattern or servlet name. The servlet filter can be configured with XML (on web.xml) or annotation. In our case, we will imagine that we want to create a log of all the requests that are sent to the server. We will also have two filters—one to log the access time and another to log the information about the browser that the client is using. To log the access time, we will create a filter called LogAccessFilter, and to log the browser information we will create a filter called LogBrowserFilter.

主站蜘蛛池模板: 林周县| 措美县| 普安县| 陆丰市| 攀枝花市| 左贡县| 曲靖市| 大渡口区| 淮滨县| 通州市| 阿图什市| 盈江县| 资源县| 温州市| 兴山县| 新巴尔虎右旗| 离岛区| 乌兰浩特市| 桂平市| 定日县| 巴马| 长泰县| 丰台区| 桐乡市| 大埔县| 嘉义县| 随州市| 元江| 忻州市| 洛川县| 朔州市| 专栏| 进贤县| 章丘市| 宁明县| 色达县| 远安县| 五指山市| 兴海县| 班玛县| 竹溪县|