servlet filters

Discussion in 'Java' started by laredotornado@zipmail.com, Aug 8, 2006.

  1. Guest

    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
    , Aug 8, 2006
    #1
    1. Advertising

  2. Luke Webber Guest

    wrote:
    > 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
    Luke Webber, Aug 8, 2006
    #2
    1. Advertising

  3. Luke Webber wrote:
    >> 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
    =?ISO-8859-2?Q?Dra=BEen_Gemi=E6?=, Aug 8, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. eti
    Replies:
    6
    Views:
    505
    Chris Smith
    Nov 24, 2003
  2. circuit_breaker
    Replies:
    2
    Views:
    1,979
    Jack Jia
    Apr 4, 2004
  3. Angus Parvis

    how do i chain up servlet filters?

    Angus Parvis, Jul 29, 2004, in forum: Java
    Replies:
    1
    Views:
    401
  4. Angus Parvis
    Replies:
    1
    Views:
    19,435
    Angus Parvis
    Aug 4, 2004
  5. Dieter Vanderelst

    using the Filters DLL (image filters)

    Dieter Vanderelst, Feb 15, 2006, in forum: Python
    Replies:
    1
    Views:
    406
    Michele Petrazzo
    Feb 15, 2006
Loading...

Share This Page