Pages Navigation Menu

Coding is much easier than you think

Difference between Struts2 FilterDispatcher and StrutsPrepareAndExecuteFilter?

Difference between Struts2 FilterDispatcher and StrutsPrepareAndExecuteFilter?

 
The FilterDispatcher is used in the early Struts2 development, and it has deprecated since Struts 2.1.3.
 
** UPDATE: Struts 2 Complete tutorial now available here.
 
If you are using Struts version >= 2.1.3, it’s recommended to upgrade the new filter class StrutsPrepareAndExecuteFilter
 
The new filter was introduced for the following reasons

  1. There were a lot of issued with the FilterDispatcher and its deployment.
  2. New Filter provides a better way to enable customizations and overrides.
  3. Make it crystal clear to developers what filters are doing what processes.
  4. make dispatch process be more flexible to support things like native operation in OSGi or plugin system.

 
For your reference, the following code should be used when you are about to use Struts version <=2.1.3

1. FilterDispatcher example

 

...
<filter>
   <filter-name>struts2</filter-name>
   <filter-class>
     org.apache.struts2.dispatcher.FilterDispatcher
   </filter-class>
</filter>
...

 
The following code should be used when you are about to use Struts version >=2.1.3

2. StrutsPrepareAndExecuteFilter example

 

...
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
...

 

About Mohaideen Jamil


Am currently working as a Struts 2 Developer in a reputed IT Organisations. I can help you with teaching Core java and Struts 2. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.