• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts' ActionServlet.init()?

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Pourang Emami
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to frameworks forum.
 
Ranch Hand
Posts: 314
2
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic