ch. 13 filters and wrappers

Post on 06-Jul-2015

320 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Chapter  13  Filters  and  Wrappers

Intercepting  the  requests  &  responses

Filters

Provide  universal  functions  that  can  be  "attached"  to  any  type  of  servlet  or  JSP  page.  • Authentication  • Logging  and  auditing  • Image  conversion  • Data  compression  • Localization  • XSL/T  transformations  of  XML  content

Filters  API

Filter,  FilterChain,  and  FilterConfig  interfaces  in  the  javax.servlet  package.    • Define  a  filter  by  implementing  the  Filter  interface.    • A  filter  chain,    • passed  to  a  filter  by  the  container,    • provides  a  mechanism  for  invoking  a  series  of  filters.  

• FilterConfig  contains  initialization  data.

Filters• Security  checks  • Reformat  headers  and  bodies  • Audit/log

• Compress    • Append  • Create  new

Modular  and  Reconfigurable  (in  DD)

Filters  are  just  like  servlets

• The  Container  knows  their  API  • The  Container  manages  their  lifecycle  • They  are  declared  in  DD

Request  tracking  filter

Stack

Declare  and  order(in  DD)

Compression  Filter(version  1)

Compression  Filter(conceptual  view)

API

Compression  Filter(version  2)

Compression  Filter(version  3)

Final  Code

Compression  Wrapper  –  helper  class

Examples

“Filter’s  Essential”  by  Oracle

top related