Javatpoint Logo

What is difference between filter and interceptor in Struts2

By: sharad*** On: Mon Oct 22 19:35:48 IST 2012     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank Profile
I am confused with the filter and interceptor,is there any difference between filter and interceptor?Up0Down

 
yes, filter is used only in web applications whereas interceptor can be used with web as well as enterprise applications.
Life cycle methods of both, also differs.
Image Created0Down

By: [email protected] On: Mon Oct 22 22:16:52 IST 2012 Question Reputation0 Answer Reputation20 Belt Series Points0 20User Image
Are You Satisfied :3Yes8No
 
the interceptor stack fires on every request.
filters only apply to the urls for which they are defined.
you use one or the other depending on need. Lets say you need to verify a cookie is present for every request. Use an interceptor. Lets say that you need to pop up an external app on some requests (driven by a url), use a filter.
Image Created0Down

By: [email protected] On: Mon Oct 22 22:20:40 IST 2012 Question Reputation0 Answer Reputation20 Belt Series Points0 20User Image
Are You Satisfied :3Yes7No
 
Sir,
How does it fire the stack on every request?
Plz clarify me in details
Image Created0Down

By: [email protected] On: Tue Jul 02 18:22:23 EDT 2013 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :1Yes5No