servlet filters

L

laredotornado

Hello,

I was just told about servlet filters. Is a new servlet filter
instantiated per request? Also, when is the "doFilter" method called
in relation to the filtered servlet's "service" method?

Thanks for the info, - Dave
 
L

Luke Webber

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
 
?

=?ISO-8859-2?Q?Dra=BEen_Gemi=E6?=

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top