my dog learned polymorphism*
The moose likes Struts and the fly likes ActionForward and Forward Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionForward and Forward Action" Watch "ActionForward and Forward Action" New topic
Author

ActionForward and Forward Action

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
Whats the difference between ActionForward and ForwardAction ? When do we use ActionForward and when ForwardAction.
Can i say ActionForward is a shorter way of doing the same thing ?
Thanks.
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 797

refer this and this

Quote from ForwardAction class

An Action that forwards to the context-relative URI specified by the parameter property of our associated ActionMapping. This can be used to integrate Struts with other business logic components that are implemented as servlets (or JSP pages), but still take advantage of the Struts controller servlet's functionality (such as processing of form beans).


SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
I would like to know when do we go for ActionForward class and when do we go for ForwardAction. ForwardAction is a StandardAction class in Struts whereas ActioForward is similar to RequestDispatcher ?

Was just wondering why execute has a return type of ForwardAction rather than ActionForward..

Thanks.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

jose chiramal wrote: ActioForward is similar to RequestDispatcher ?

No, ActionForward is the decision taken by the RequestDispatcher in order to forward to next resource.
jose chiramal wrote:Was just wondering why execute has a return type of ForwardAction rather than ActionForward..

Do you want to say opposite of it ?


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
Sorry , my mistake should have been "Was just wondering why execute has a return type of ActionForward rather than ForwardAction.."
I find the both very confusing
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Well, they are confusing, but to make it simple, remember:
1. ActionForward: One which is a return type of Action#execute() method and used by RequestDispatcher.
2. ForwardAction: Dummy (not exactly) action which can be used to delegate to the servlet or any other business logic implementer which can utilize the Struts other functionality, like ActionForm.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionForward and Forward Action