-1

i'm new in servlet and want to know that what's the benifit of filter in servlet? and don't understand exactly what's the use of Filter? can you explain me with an example?

help would be appreciated!!

1 Answers1

0

Filters not create a response like servlet. A filter is an object that can transform a request or alter a response before it reaches to a servlet and can process response before it leaves to a servlet.

  • A filter can intercept a servlet's invocation before the servlet is called .

  • Can examine a request before a servlet is called.

  • Can modify the request headers and request data by providing a customized version of the request object that wraps the real request.
  • Can modify the response headers and response data by providing a customized version of the response object that wraps the real response.
  • Intercept a servlet's invocation after the servlet is called.
Sanjay Rabari
  • 2,091
  • 1
  • 17
  • 32