Hi, can i call other methods in struts Action class with out calling execute() method?i don't want execute() to execute,but for each request for same action one user defined method needs to execute ,is it possible? Regards Venkat
I would suggest that you describe what you are trying to do. While it is technically possible for you to create a new instance of your action class from another action or other Java code and then start calling method on the action, I would generally describe this as bad design. If you have common code that you have to access from multiple actions I would move it out of the action and into a new class...or into your business layer.
To correct the first response: The answer is yes for struts 1 as well, take a look at DispatchAction. Instead of it executing the execute method you pass a parameter to it and it will execute that method as well, which you would define the parameter name in your struts config. So you can do things like myAction.do?parameter=save. When that is executed it will look for a method signature of save(...)
It will throw an error if it cannot find the method, there are ways of taking care of that. It's not the prettiest but it does get the job done if you're stuck with struts 1. I normally used it for CRUD functions and override the unspecified(...) to display the page and list the objects. Then my links on the page will pass parameters in to save, edit, delete, thus calling those methods in my action. If you need an example let me know and I'll copy an example in.