ch. 13 filters and wrappers

17
Chapter 13 Filters and Wrappers Intercepting the requests & responses

Upload: manolis-vavalis

Post on 06-Jul-2015

320 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Ch. 13 filters and wrappers

Chapter  13  Filters  and  Wrappers

Intercepting  the  requests  &  responses

Page 2: Ch. 13 filters and wrappers

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

Page 3: Ch. 13 filters and wrappers

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.

Page 4: Ch. 13 filters and wrappers

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

• Compress    • Append  • Create  new

Page 5: Ch. 13 filters and wrappers

Modular  and  Reconfigurable  (in  DD)

Page 6: Ch. 13 filters and wrappers

Filters  are  just  like  servlets

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

Page 7: Ch. 13 filters and wrappers

Request  tracking  filter

Page 8: Ch. 13 filters and wrappers

Stack

Page 9: Ch. 13 filters and wrappers

Declare  and  order(in  DD)

Page 10: Ch. 13 filters and wrappers

Compression  Filter(version  1)

Page 11: Ch. 13 filters and wrappers

Compression  Filter(conceptual  view)

Page 12: Ch. 13 filters and wrappers

API

Page 13: Ch. 13 filters and wrappers

Compression  Filter(version  2)

Page 14: Ch. 13 filters and wrappers

Compression  Filter(version  3)

Page 15: Ch. 13 filters and wrappers

Final  Code

Page 16: Ch. 13 filters and wrappers

Compression  Wrapper  –  helper  class

Page 17: Ch. 13 filters and wrappers

Examples

“Filter’s  Essential”  by  Oracle