1
Filter Filter is a web component like servlet whose life cycle will be managed by web container. Filter component has following three life cycle methods: ----------- Void init(FilterConfig)throws ServletException ; Void doFilter(ServletRequest,ServletResponse,FilterChain)IOException,Ser vletException; Void destroy() Filter component will be used to intercept the request and response. When send the request to the servlet container invokes the servlet service method. Before invoking the servlet service method you can stop the request and you can do some processing on the request .this is called as pre- processing the request you can do this by adding your printer. Common task which you can do in pre-processing are Verify the security information Login information about the client in the log file. Verifying the session is valid or not etc. Once the request processing is completed by the servlet and response is ready you can stop the response which is going to the client and you perform some task under response this is called as post-processing. Following are the some common task which you can perform in post – processing: --------- Compressing the data. Applying the encryption algorithm on data. Login the information about the response in log file. Pre-processing Request processing Post – processing Hello.html Filter I Filter II Login servlet Enter Name 1) Collect the name Collect the IP address IP address in log file Collect the message 1) Collect the name 2) Collect the IP address 3) Log into log file 4) Prepare the message Cli HELLO ----- RAJIV SHYAM YOUR REQUEST HAVE BEEN PLACES SUCCESFULLY

Filter ds

  • Upload
    phani

  • View
    213

  • Download
    1

Embed Size (px)

DESCRIPTION

Filter

Citation preview

FilterFilter is a web component like servlet whose life cycle will bemanaged by web container. Filter componenthas following three life cycle methods: ----------- Void init(FilterConfig)throws Servlet!ception " Void doFilter(Servlet#e$%est&Servlet#esponse&FilterChain)'(!ception&Servlet!ception" Void destroy()Filter component will be %sed to intercept the re$%est and response. )hen send the re$%est to the servlet container invokes the servlet service method.*efore invoking the servlet service method yo% can stop the re$%est and yo% can do some processing on the re$%est .this is called as pre-processing the re$%est yo% can do this by adding yo%r printer.Common task which yo% can do in pre-processing are Verify the sec%rity information +ogin information abo%t the client in the log file. Verifying the session is valid or not etc.(nce the re$%est processing is completed by the servlet and response is ready yo% can stop the response which is going to the client and yo% perform some task %nder response this is called as post-processing.Following are the some common task which yo% can perform in post ,processing: --------- Compressing the data. -pplying the encryption algorithm on data. +ogin the information abo%t the response in log file. .re-processing #e$%est processing .ost , processing /ello.html /elloFilter /elloServletFilter'Filter ''+oginservletnter 0ame 1) Collect the name 2) Collect the '. address3) +og the name and'. address in log file 4) Forward to the /elloServlet5) Collect the message prepared 6) +og into log file 1) Collect the name 2) Collect the '. address3) +og into log file 4) .repare the message 5) Store the message %n re$%est Click /++( -----#-7'V S/8-9 YOUR REQUEST HAVE BEENPLACES SUCCESFULLYGood night