Controller Extension Points
The next set of possible extension points is within the controller layer. Some of these have been mentioned briefly in previous chapters, but they’re repeated here for completeness.
Extending the ActionServlet Class
In
earlier versions of the Struts framework, it was almost a given that
an application needed to extend the ActionServlet
class because most of the controller functionality, excluding the
Action class behavior, was present in this class.
With Struts 1.1, this is no longer true. However, there are still a
few good reasons why you might need to extend the
ActionServlet class.
As was pointed out in Chapter 5, the
initialization routines that are invoked when a Struts application is
first launched reside in the ActionServlet class.
If you need to modify the way the framework initializes itself, this
is the place to do so. To extend the ActionServlet
class, just create a subclass of
org.apache.struts.action.ActionServlet. You can
then override the method or methods that you need to function
differently. Once this is done, you need to modify the deployment
descriptor so that the Struts application will use your custom
ActionServlet:
<servlet> <servlet-name>storefront</servlet-name> <servlet-class> com.oreilly.struts.storefront.framework.ExtendedActionServlet </servlet-class> </servlet>
Most of the runtime request-processing behavior has been moved to the
RequestProcessor class in Struts 1.1. If you need to customize the manner in which your Struts ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access