J2EE Explorer: uses Java Servlets 2.4 for filtering
Source: Internet
Author: User
Servlet APIs have long ago become the cornerstone of enterprise application development, while Servlet filters are a relatively new supplement to The J2EE family. In the last article of the J2EE Explorer series, the author Kyle Gabhart will introduce you to the Servlet Filter architecture and define many applications of filters, it also guides you through three steps to implement a typical filter. He will also reveal some exciting changes to bean, which are expected to be introduced in the newly released Java Servlet 2.4 specification.
Servlet filters are pluggable Web components that allow us to implement preprocessing and post-processing logic in Web applications. Filters support basic request processing functions of servlet and JSP pages, such as logging, performance, security, session processing, XSLT conversion, and so on.
The filter was initially released along with the Java Servlet 2.3 Specification, and was significantly upgraded by the recently finalized 2.4 specification. In the last part of this J2EE Explorer series, I will introduce you to the basic knowledge of Servlet filters, such as the overall architecture design and implementation details, typical applications in J2EE Web applications will also involve some extended functions that are expected to be provided by the latest Servlet specifications.
What is a Servlet Filter?
Servlet filters are small Web components that intercept requests and responses to view, extract, or operate in some way the data being exchanged between the client and the server. Filters are Web components that typically encapsulate some functions. These functions are important but not decisive for processing client requests or sending responses. Typical examples include recording data about requests and responses, processing security protocols, and managing session attributes. Filters provide an object-oriented modularization mechanism to encapsulate common tasks into pluggable components that are declared in a configuration file and processed dynamically.
Servlet filters combine many elements to make filters unique, powerful, and modular Web components. That is to say, the Servlet Filter is:
Declarative: The filter is declared through the xml tag in the Web deployment descriptor (web. XML. This allows you to add and delete filters without modifying any application code or JSP pages.
Dynamic: the Servlet container calls the filter at runtime to intercept and process requests and responses.
Flexible: filters are widely used in Web processing environments and cover many of the most common auxiliary tasks, such as logging and security. Filters are flexible because they can be used to perform preprocessing and post-processing for direct calls from clients and to process requests scheduled between Web components after the firewall. Finally, you can link the filter to provide the required functions.
Modular: by encapsulating the application processing logic into a single class file, the filter defines modular units that can be easily added or deleted from the request/response chain.
Portable: like many other aspects of the Java Platform, Servlet filters are portable across platforms and containers, further supporting the modularization and reusable nature of Servler filters.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service