SlideShare a Scribd company logo
1 of 20
Created By
Amit Tomer
 Describe the web container request cycle
 Describe the Filter API
 Develop a filter class
 Configure a filter in the web.xml file
Objectives
Amit Tomer 2
 Request processing by the web container
 Applying filters to an incoming request
 Applying filters to a dispatched request
Web Container Request Cycle
Amit Tomer 3
 Request and response objects are created for each
incoming request.
Web Container Request Cycle
Amit Tomer 4

Applying Filters to an Incoming
Request
 A filter intercepts the request before it gets to the
requested resource.
 A response is returned to the client through the
filter.
Amit Tomer 5

Applying Filters to an Incoming
Request (Contd.)
Multiple filters can intercept a given request.
This provides for modularity and reuse of code.
Amit Tomer 6

Applying Filters to an Incoming
Request (Contd.)
 Filters can be applied to different requests in
different combinations.
Amit Tomer 7

Applying Filters to an Incoming
Request (Contd.)
 Filters can be used for many activities in a web
application, such as:
 Blocking access to a resource based on user identity or
role membership
 Auditing incoming requests
 Compressing the response data stream
 Transforming the response
 Measuring and logging servlet performance
Amit Tomer 8

Filters Applied to a Dispatch
 Filters can be applied to an internal dispatch, such as
a request forward or include.
 This behavior is determined by the information in
the deployment descriptor.
Amit Tomer 9

Filter API
Amit Tomer 10

The init Method
 The init method is called once when the filter
instance is first created.
 Use the init method to:
 Perform one-time initialization of resources the filter
uses over its lifetime
 Retrieve the initialization parameters configured in the
deployment descriptor
public void init(FilterConfig config)
throws ServletException {
}
Amit Tomer 11

The doFilter Method
 The doFilter method is the filter equivalent of a
servlet’s service method.
 As a developer, you implement the doFilter method
to do the following:
 Perform the operations you want to occur every time
the filter is invoked.
 Decide whether to pass the request to the next
component in the filter chain or halt the request
entirely.
 To pass on the request, call the doFilter method on the
FilterChain reference.
Amit Tomer 12

The destroy Method
 The destroy method is the last method called in the
life cycle of a filter instance.
 Use the destroy method to clean up any resources
allocated in the init method.
public void destroy() {
}
Amit Tomer 13

Configuring the Filter
 You declare the filter in the deployment descriptor.
 You can supply initialization parameters in the
declaration.
<filter>
<filter-name>perfFilter</filter-name>
<filter-class>sl314.web.PerformanceFilter
</filter-class>
<init-param>
<param-name>Log Entry Prefix</param-name>
<param-value>Performance: </param-value>
</init-param>
</filter>
Amit Tomer 14

Configuring the Filter(Contd…)
 Mappings can be:
 URL based – Use the exact URL or a wildcard (*)
 Servlet name-based – Specify the name of the servlet to
which the filter is applied
<filter-mapping>
<filter-name>perfFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
 For a given request, if multiple filter mappings match:
 URL-based filters applied before servlet name-based filters
 Filters applied in the order in which the mappings occur in
the deployment descriptor
Amit Tomer 15

Configuring the Filter (Contd.)
Just A Minute
 Given these servlet mappings, what happens if the client requests
/admin/add_league.do?
<servlet-mapping>
<servlet-name>FrontController</servlet-name>
</url-pattern>*.do</url-pattern>
</servlet-mapping>
<filter-mapping>
<filter-name>perfFilter</filter-name>
<servlet-name>FrontController</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>auditFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>transformFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping> Amit Tomer 16

Configuring the Filter(Contd…)
 Typically, filters are applied to requests from a client.
You can specify the dispatcher element in a filter
mapping. This determines what type (or types) of
requests invoke the filter. Valid values are:
 REQUEST – The filter is applied if the request is from
a client.
 INCLUDE – The filter is applied if the request is from
a request dispatcher include.
 FORWARD – The filter is applied if the request is from
a request dispatcher forward.
 ERROR – The filter is applied if the request is a result
of an error condition.
Amit Tomer 17

Configuring the Filter(Contd…)
 Typically, filters are applied to requests from a client.
You can specify the dispatcher element in a filter
mapping. This determines what type (or types) of
requests invoke the filter. Valid values are:
 REQUEST – The filter is applied if the request is from
a client.
 INCLUDE – The filter is applied if the request is from
a request dispatcher include.
 FORWARD – The filter is applied if the request is from
a request dispatcher forward.
 ERROR – The filter is applied if the request is a result
of an error condition.
Amit Tomer 18

Configuring the Filter(Contd…)
 You can use a combination of dispatcher elements to
specify when filters should be applied.
 Given:
<filter-mapping>
<filter-name>auditFilter</filter-name>
<url-pattern>*.do</url-pattern>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
 When would the auditFilter be applied?
Amit Tomer 19

Summary
 Filters permit you to augment the default request
processing model.
 You can create a filter as follows:
 Implementing the javax.servlet.Filter interface
 Configuring a filter instance in the deployment
descriptor
 Configuring one or more filter mappings
 Filters can also be applied to dispatched requests
Amit Tomer 20

More Related Content

Similar to Web Container Request Cycle, Filter API, and Filter Configuration

Servlets - filter, listeners, wrapper, internationalization
Servlets -  filter, listeners, wrapper, internationalizationServlets -  filter, listeners, wrapper, internationalization
Servlets - filter, listeners, wrapper, internationalizationsusant sahu
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9...WebStackAcademy
 
ASP.NET MVC controllers
ASP.NET MVC controllersASP.NET MVC controllers
ASP.NET MVC controllersMahmoud Tolba
 
ASP.NET MVC_Routing_Authentication_Aurhorization.pdf
ASP.NET MVC_Routing_Authentication_Aurhorization.pdfASP.NET MVC_Routing_Authentication_Aurhorization.pdf
ASP.NET MVC_Routing_Authentication_Aurhorization.pdfsetit72024
 
Intercepting Filters Design Pattern
Intercepting Filters Design PatternIntercepting Filters Design Pattern
Intercepting Filters Design PatternProdigyView
 
Sling Component Filters in CQ5
Sling Component Filters in CQ5 Sling Component Filters in CQ5
Sling Component Filters in CQ5 connectwebex
 
Android Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptxAndroid Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptxKNANTHINIMCA
 
Ch. 13 filters and wrappers
Ch. 13 filters and wrappersCh. 13 filters and wrappers
Ch. 13 filters and wrappersManolis Vavalis
 
software requirement specification
software requirement specificationsoftware requirement specification
software requirement specificationmaliksiddique1
 
Enterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin BlockEnterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin Blockmcgurk
 
Elments Used on Jmeter
Elments Used on JmeterElments Used on Jmeter
Elments Used on JmeterViviana Lesmes
 
Design patterns in Magento
Design patterns in MagentoDesign patterns in Magento
Design patterns in MagentoDivante
 
Flex modular applications using robotlegs
Flex modular applications using robotlegsFlex modular applications using robotlegs
Flex modular applications using robotlegsSaurabh Narula
 

Similar to Web Container Request Cycle, Filter API, and Filter Configuration (20)

Servlets - filter, listeners, wrapper, internationalization
Servlets -  filter, listeners, wrapper, internationalizationServlets -  filter, listeners, wrapper, internationalization
Servlets - filter, listeners, wrapper, internationalization
 
Listeners and filters in servlet
Listeners and filters in servletListeners and filters in servlet
Listeners and filters in servlet
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9...
 
Servlet Filter
Servlet FilterServlet Filter
Servlet Filter
 
ASP.NET MVC controllers
ASP.NET MVC controllersASP.NET MVC controllers
ASP.NET MVC controllers
 
ASP.NET MVC_Routing_Authentication_Aurhorization.pdf
ASP.NET MVC_Routing_Authentication_Aurhorization.pdfASP.NET MVC_Routing_Authentication_Aurhorization.pdf
ASP.NET MVC_Routing_Authentication_Aurhorization.pdf
 
Adaptive filters
Adaptive filtersAdaptive filters
Adaptive filters
 
Level 4
Level 4Level 4
Level 4
 
Intercepting Filters Design Pattern
Intercepting Filters Design PatternIntercepting Filters Design Pattern
Intercepting Filters Design Pattern
 
Sling Component Filters in CQ5
Sling Component Filters in CQ5 Sling Component Filters in CQ5
Sling Component Filters in CQ5
 
Wcf routing kt
Wcf routing ktWcf routing kt
Wcf routing kt
 
Android Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptxAndroid Application Components-BroadcastReceiver_Content Provider.pptx
Android Application Components-BroadcastReceiver_Content Provider.pptx
 
Ch. 13 filters and wrappers
Ch. 13 filters and wrappersCh. 13 filters and wrappers
Ch. 13 filters and wrappers
 
software requirement specification
software requirement specificationsoftware requirement specification
software requirement specification
 
Enterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin BlockEnterprise Library 3.0 Policy Injection Applicatoin Block
Enterprise Library 3.0 Policy Injection Applicatoin Block
 
Servlet
ServletServlet
Servlet
 
Elments Used on Jmeter
Elments Used on JmeterElments Used on Jmeter
Elments Used on Jmeter
 
Design patterns in Magento
Design patterns in MagentoDesign patterns in Magento
Design patterns in Magento
 
Flex modular applications using robotlegs
Flex modular applications using robotlegsFlex modular applications using robotlegs
Flex modular applications using robotlegs
 
Android Security
Android SecurityAndroid Security
Android Security
 

Recently uploaded

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Recently uploaded (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Web Container Request Cycle, Filter API, and Filter Configuration

  • 2.  Describe the web container request cycle  Describe the Filter API  Develop a filter class  Configure a filter in the web.xml file Objectives Amit Tomer 2
  • 3.  Request processing by the web container  Applying filters to an incoming request  Applying filters to a dispatched request Web Container Request Cycle Amit Tomer 3
  • 4.  Request and response objects are created for each incoming request. Web Container Request Cycle Amit Tomer 4
  • 5.  Applying Filters to an Incoming Request  A filter intercepts the request before it gets to the requested resource.  A response is returned to the client through the filter. Amit Tomer 5
  • 6.  Applying Filters to an Incoming Request (Contd.) Multiple filters can intercept a given request. This provides for modularity and reuse of code. Amit Tomer 6
  • 7.  Applying Filters to an Incoming Request (Contd.)  Filters can be applied to different requests in different combinations. Amit Tomer 7
  • 8.  Applying Filters to an Incoming Request (Contd.)  Filters can be used for many activities in a web application, such as:  Blocking access to a resource based on user identity or role membership  Auditing incoming requests  Compressing the response data stream  Transforming the response  Measuring and logging servlet performance Amit Tomer 8
  • 9.  Filters Applied to a Dispatch  Filters can be applied to an internal dispatch, such as a request forward or include.  This behavior is determined by the information in the deployment descriptor. Amit Tomer 9
  • 11.  The init Method  The init method is called once when the filter instance is first created.  Use the init method to:  Perform one-time initialization of resources the filter uses over its lifetime  Retrieve the initialization parameters configured in the deployment descriptor public void init(FilterConfig config) throws ServletException { } Amit Tomer 11
  • 12.  The doFilter Method  The doFilter method is the filter equivalent of a servlet’s service method.  As a developer, you implement the doFilter method to do the following:  Perform the operations you want to occur every time the filter is invoked.  Decide whether to pass the request to the next component in the filter chain or halt the request entirely.  To pass on the request, call the doFilter method on the FilterChain reference. Amit Tomer 12
  • 13.  The destroy Method  The destroy method is the last method called in the life cycle of a filter instance.  Use the destroy method to clean up any resources allocated in the init method. public void destroy() { } Amit Tomer 13
  • 14.  Configuring the Filter  You declare the filter in the deployment descriptor.  You can supply initialization parameters in the declaration. <filter> <filter-name>perfFilter</filter-name> <filter-class>sl314.web.PerformanceFilter </filter-class> <init-param> <param-name>Log Entry Prefix</param-name> <param-value>Performance: </param-value> </init-param> </filter> Amit Tomer 14
  • 15.  Configuring the Filter(Contd…)  Mappings can be:  URL based – Use the exact URL or a wildcard (*)  Servlet name-based – Specify the name of the servlet to which the filter is applied <filter-mapping> <filter-name>perfFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping>  For a given request, if multiple filter mappings match:  URL-based filters applied before servlet name-based filters  Filters applied in the order in which the mappings occur in the deployment descriptor Amit Tomer 15
  • 16.  Configuring the Filter (Contd.) Just A Minute  Given these servlet mappings, what happens if the client requests /admin/add_league.do? <servlet-mapping> <servlet-name>FrontController</servlet-name> </url-pattern>*.do</url-pattern> </servlet-mapping> <filter-mapping> <filter-name>perfFilter</filter-name> <servlet-name>FrontController</servlet-name> </filter-mapping> <filter-mapping> <filter-name>auditFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter-mapping> <filter-name>transformFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> Amit Tomer 16
  • 17.  Configuring the Filter(Contd…)  Typically, filters are applied to requests from a client. You can specify the dispatcher element in a filter mapping. This determines what type (or types) of requests invoke the filter. Valid values are:  REQUEST – The filter is applied if the request is from a client.  INCLUDE – The filter is applied if the request is from a request dispatcher include.  FORWARD – The filter is applied if the request is from a request dispatcher forward.  ERROR – The filter is applied if the request is a result of an error condition. Amit Tomer 17
  • 18.  Configuring the Filter(Contd…)  Typically, filters are applied to requests from a client. You can specify the dispatcher element in a filter mapping. This determines what type (or types) of requests invoke the filter. Valid values are:  REQUEST – The filter is applied if the request is from a client.  INCLUDE – The filter is applied if the request is from a request dispatcher include.  FORWARD – The filter is applied if the request is from a request dispatcher forward.  ERROR – The filter is applied if the request is a result of an error condition. Amit Tomer 18
  • 19.  Configuring the Filter(Contd…)  You can use a combination of dispatcher elements to specify when filters should be applied.  Given: <filter-mapping> <filter-name>auditFilter</filter-name> <url-pattern>*.do</url-pattern> <dispatcher>INCLUDE</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>  When would the auditFilter be applied? Amit Tomer 19
  • 20.  Summary  Filters permit you to augment the default request processing model.  You can create a filter as follows:  Implementing the javax.servlet.Filter interface  Configuring a filter instance in the deployment descriptor  Configuring one or more filter mappings  Filters can also be applied to dispatched requests Amit Tomer 20