What is switch action & forwardAction in struts

Showing Answers 1 - 9 of 9 Answers

Rafiq

  • Feb 12th, 2007
 

Switch action is used to navigate/move from one module to other module in struts, where as forwardAction is used is used to navigate/move within same module

ArulMurugan

  • Feb 13th, 2007
 

A Forward Action is a standard Action forwards the request to the context-relative URI(JSP/Servlet) specified by the parameter property of the associated ActionMapping.To configure the use of the Forward Action in your struts-config.xml file, create an entry like this: which will forward control to the context-relative URI specified by the parameter attribute.A Switch Action is a standard Action that switches to a new module and then forwards control to a URI within the new module. Switch Action elements are used only in applications consisting of more than one module. Valid request parameters for this Action are:page - Module-relative URI (beginning with "/") to which control should be forwarded after switching. prefix - The module prefix (beginning with "/") of the module to which control should be switched. Use a zero-length string for the default module. The appropriate ModuleConfig object will be stored as a request attribute, so any subsequent logic will assume the new module. Action Mapping in struts-config.xml looks as follows.To link to a page in another module, use a URI as followshttp://localhost:8080/mywebapp/toModule.do?prefix=/myModule&page=/index.jspThe Swtich Action, first switch to myModule and forward to index.jsp in myModule.

when we are using multiple modules in that case i need to maintain different struts configuration files so i need to provide multiple struts configuration files in the web.xml in such situation i use SwitchAction to switch to which configuration file is executed.But ForwardAction is same as like forward tag in jsp tags.I want to say real time situation.I have a project that project is implemented in old jsp and servlets only and there is no framework is implemented in that project and i want to upgrade the old project to new with struts framework then in that situation instead of forward tag in jsp i use ForwardAction in struts so what is the need means flexibility with framework is more

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions