Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Struts and the fly likes Filter Vs Interceptor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Filter Vs Interceptor" Watch "Filter Vs Interceptor" New topic
Author

Filter Vs Interceptor

rajiv shrestha
Ranch Hand

Joined: Aug 25, 2010
Posts: 30
need information about this
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

Have you done any research of your own?? Filters are related to Servlet spec and Interceptors are part of Struts. Can you tell us what type of information you want on this. Please put in some efforts when asking a question...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Motilal Daravatu
Greenhorn

Joined: May 10, 2012
Posts: 1
What is difference between Filter and Interceptor, when to use one, in which scenario ..


Definition:
A filter dynamically intercepts requests and responses to transform or use the information contained in the requests or responses. Filters typically do not themselves create responses, but instead provide universal functions that can be "attached" to any type of servlet or JSP page.


Filters can perform many different types of functions. We'll discuss examples of the italicized items in this paper:
Authentication-Blocking requests based on user identity.
Logging and auditing-Tracking users of a web application.
Image conversion-Scaling maps, and so on.
Data compression-Making downloads smaller.
Localization-Targeting the request and response to a particular locale.
Interceptors
Interceptors are used in conjunction with Java EE managed classes to allow developers to invoke interceptor methods in conjunction with method invocations or lifecycle events on an associated target class. Common uses of interceptors are logging, auditing, or profiling.

Interceptors can be defined within a target class as an interceptor method, or in an associated class called an interceptor class. Interceptor classes contain methods that are invoked in conjunction with the methods or lifecycle events of the target class.
 
Don't get me started about those stupid light bulbs.
 
subject: Filter Vs Interceptor