This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi I have some activities to take place just at the beginning of my application. How can I get access to ActionServlet to put them inside it's init() method? (I looked for this file every where in my root directory inside jdeveloper/mywork/wrkspc/prj/.. but I couldn't find it.) Is there any other way to do it? Thank you for your time. Best Regards, Pourang Emami
The source code for Struts can be downloaded from the Apache.org site. Another solution that would not involve the modification of the Struts ActionServlet would be to create your own servlet that is loaded on application startup and to put your code in it's init() method. In my opinion this would be preferable to modifying the Struts servlet as it would mean that you would not have to re-apply the modification if you decided to move to another version of Struts.
Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
Joined: Sep 21, 2002
Dear Andy Actually this is exactly the kind of job I've done.I have created a class extending ActionServlet and put the codes inside it's init(). But according a friend, this is the ActionServlet is called at the start-up and so by having another class clled in the start-up I will get the control out of the ActionServlet? Any idea?
Hi there, If you want to do a one-time run some code during startup of a Struts application, the recommended way to do it (in Struts 1.1) is to develop a plugin. You do this as follows: 1. Create a class that implements the org.apache.struts.action.PlugIn interface. 2. Create an init () method in the new class that contains your startup code. See the PlugIn API for the specifics on what needs to be done here. 3. Register the plug-in at the bottom of the struts-config.xml file. See the struts-config.xml DTD on how to do this. And that should be it. If, on the other handle, you want to modify and extend the behaviour of Struts' RequestProcessor (for example, if you want to modify Struts' handling of action-based security), then you should do the following: 1. Create a class that implements org.apache.struts.action.RequestProcessor. 2. Override the appropriate method whose behaviour you want to modify. For instance, if you want to modify Struts' handling of action-based security, override the 'processRoles' method. See the RequestProcessor API for a complete list of methods. 3. Register your RequestProcessor in the struts-config.xml file using the '<controller />' tag. See the struts-config.xml DTD for more information on how to do this. BTW, the Struts Tiles plugin implements its own RequestProcessor, so if you want to use your RequestProcessor alongside the Tiles' RequestProcessor, make sure your processor extends TilesRequestProcessor instead of implementing RequestProcessor. If you don't Tiles will crap out during start-up. Cheers, Darryl
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com