O'Reilly logo

Programming Jakarta Struts, Second Edition by Chuck Cavaness

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 one of the places 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required