Pages Navigation Menu

Coding is much easier than you think

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

 

...

   struts2
   
     org.apache.struts2.dispatcher.FilterDispatcher
   

...

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

2. StrutsPrepareAndExecuteFilter example

 

...

struts2

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter


...