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:
- <filter>
- <filter-name>Page Request Timer filter-name>
- <filter-class>TimeTrackFilter filter-class>
- filter>
- <filter-mapping>
- <filter-name>Page Request Timer filter-name>
- <servlet-name>Main Servlet servlet-name>
- filter-mapping>
- <servlet>
- <servlet-name>Main Servlet servlet-name>
- <servlet-class>MainServlet servlet-class>
- servlet>
- <servlet-mapping>
- <servlet-name>Main Servlet servlet-name>
- <url-pattern>/* url-pattern>
- 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.
- Servlet Container matching process
- How to call Servlet to process requests
- Extended Future Response Servlet
- Three methods for compiling Servlet
- Transactions in Servlet containers