Servlet filter configuration details

Source: Internet
Author: User

Servlet filter configuration

The filter is declared through two xml tags in the web. XML file. The tag defines the name of the filter and declares the implementation class and the init () parameter. Tags associate the Servlet filter or URL mode.

The list is taken from a web. xml file. It shows how to declare the inclusion relationship of the Servlet filter:
The configuration of a Servlet filter is declared in web. xml:

 
 
  1. <filter> 
  2. <filter-name>Page Request Timer filter-name> 
  3. <filter-class>TimeTrackFilter filter-class> 
  4. filter> 
  5. <filter-mapping> 
  6. <filter-name>Page Request Timer filter-name> 
  7. <servlet-name>Main Servlet servlet-name> 
  8. filter-mapping> 
  9. <servlet> 
  10. <servlet-name>Main Servlet servlet-name> 
  11. <servlet-class>MainServlet servlet-class> 
  12. servlet> 
  13. <servlet-mapping> 
  14. <servlet-name>Main Servlet servlet-name> 
  15. <url-pattern>/* url-pattern> 
  16. servlet-mapping> 

The code example above illustrates the Servlet filter configuration "Page Request Timer") and maps it to a Servlet "Main Servlet "). Then a Servlet ing is defined for the Servlet so that each request is specified by a wildcard) is sent to the Servlet. This is a typical ing Declaration of the Controller component. Pay attention to the order of these declarations, because the order of these elements cannot be deviated.

  1. Servlet Container matching process
  2. How to call Servlet to process requests
  3. Extended Future Response Servlet
  4. Three methods for compiling Servlet
  5. Transactions in Servlet containers

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.