Posts

Showing posts with the label filter

Filter for your Servlet

Image
Filter is used to perform filtering tasks on the request or the response or both. It is an interface in the javax.servlet package. Filters can be used for the following purposes: 1) Authentication Filters  2) Logging and Auditing Filters  3) Image conversion Filters  4) Data compression Filters  5) Encryption Filters  6) Tokenizing Filters  7) Filters that trigger resource access events  8) XSL/T filters  9) Mime-type chain Filter  Filters have the following three methods: Simple example of using filter for pre and post processing of response. This is how my project looks like: MyFilter will be applied before and after our MyServlet. Here is the code: index.html <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1" > <title> Insert title here </title> </head> <body> Welcome! </body> </html> web.xml <web-app> <serv...