> Hello,
>
> I was just told about servlet filters. Is a new servlet filter
> instantiated per request?
No. The lifecycle of a filter is similar to that of a servlet. One
instance per VM, multithreaded.
> Also, when is the "doFilter" method called
> in relation to the filtered servlet's "service" method?
The filter gets called first, then should chain to any other filters via
the FilterChain's doFilter method. If it's the last filter in the chain,
doFilter will pass control to the servlet's service method.
Luke
Dražen Gemić - 08 Aug 2006 13:54 GMT
>> Also, when is the "doFilter" method called
>> in relation to the filtered servlet's "service" method?
Filters are usefull for processing requests before
they are resolved.
Filter does not create response, it routes request to the component(s)
that will respond to it. That means that one can preprocess the request
and forward it to a servlet for response.
DG