I’m trying to integrate Struts 2 with Spring and Hibernate. There are things that I don’t understand in the web.xml :
What’s the difference between the Struts 2 “filter-class” tags which have the following values:
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter <br/>
or
org.apache.struts2.dispatcher.FilterDispatcher <br/><br/>
Why do we use a Filter for Struts and use a Listener for Spring, and shat is the difference between them.
Why in some projects we can omit the hibernate filter and in the others we use it.
Its like a lot of questions and here are answers to few of them.
StrutsPrepareAndExecuteFilterare there to perform same work andStrutsPrepareAndExecuteFilteris the latest version ofFiterDispatcherwith a lots of improvement and keep in mind the future needs. So in shortFiterDispatcheris deprecated.StrutsPrepareAndExecuteFilteris the entry point of S2 and is responsible for handling any request and response.In short Filter is used for monitoring request and response from client to the servlet, or to modify the request and response, or to audit and log.So this gives a brief idea about whey we are using Filters for S2 and Listeners for Spring and you can do more googling to get more information about there differences and how hey work.
Hibernate filters are used in some specific use-cases.one such use case is to filtering the results of searches. Sometimes it is required to only process a subset of the data in the underlying Database tables and there can be many more such use case for hibernate filters and they only come in to play if you need them.