aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Listeners Vs Filters Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Listeners Vs Filters" Watch "Listeners Vs Filters" New topic
Author

Listeners Vs Filters

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
It says that we can use filters to track the user request but all these we can do by listeners also so why filters ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35258
    
    7
What kind of listener would you use that gets activated by an incoming request?


Android appsImageJ pluginsJava web charts
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

You may use ServletRequestListener.


SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4725

With filters you can use the Chain of Responsibility pattern whereas I do not think this could be accomplished with the listener.

The filters' implementation of Chain of Responsibility allows you to wrap the request or response using the Decorator pattern. This is something else that the listener does not allow you to do.

Oh, and I think the listener can only be run when a request is created or destroyed. This means it can not be configured to run during a forwarding of a request - but as I recall it is possible to configure listeners to run on any of the different kinds of dispatching on a request.


A good workman is known by his tools.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Listeners Vs Filters
 
Similar Threads
How often the listeners as well as filters are used in applications by companies??
IBM 484
Filter vs Listener to keep track of session instances
possible ways to pass session from servlets to jsp?
What to use where?