*
The moose likes Struts and the fly likes ActionForward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionForward" Watch "ActionForward" New topic
Author

ActionForward

pendse anagha
Ranch Hand

Joined: Mar 09, 2005
Posts: 44
Hello ,
I have little experience in struts technology - and I have joined a company where they are extensively using struts .

In many catch Blocks I see the code :

I dont seem to understand why we should be doing this ?

Can I not use :


Thanks to all in advance ,
anagha
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
What this code is saying is "go back to the jsp that called this action". you need "new", because you are instantiating an object using it's constructor.

Here's a link to the struts JavaDoc which answers most of these questions:

http://struts.apache.org/api/overview-summary.html


Merrill
Consultant, Sima Solutions
pendse anagha
Ranch Hand

Joined: Mar 09, 2005
Posts: 44
Hello Merrill,
Thanks for your reply .
I did check the site that you have so kindly pointed me to .

Couple of more questions come to mind :

Is the creation of a new ActionForward related to maintaining the request ?
ie when I create a new ActionForward - will the struts framework actually do a
RequestDespatcher.forward ? ( thereby maintaining my httpRequest )
and - when I just simply do a mapping.findForward does that mean - that it actually does a response.sendRedirect ( new request )

Thanks for your answers - just wanted to confirm my understanding

-anagha
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In the Struts architecture, when any action is called (e.g. MyAction.do) it's the Struts ActionServlet that is actually being called. This servlet then reads the struts-config.xml file and calls the execute() method on the appropriate Action class. When the execute() method you write terminates, it must return an instance of ActionForward to the Struts ActionServlet.

When ActionServlet receives this object, it then performs a RequestDispatcher.forward() to the appropriate jsp defined by the ActionFoward. The mapping.findForward() method does nothing more than instantiate an ActionForward class from the name given in the struts-config.xml file. It's the Struts ActionServlet that does the forwarding using the information you pass back to it in the form of an ActionForward instance.

I hope this helps. Good luck.

[ March 09, 2005: Message edited by: Merrill Higginson ]
[ March 09, 2005: Message edited by: Merrill Higginson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionForward
 
Similar Threads
html submit button javascript issue
saveErrors method in Action class
DynaValidatorForm question:
Page expires using history.back
Mapping.getInput() always returns null