What is struts flow? Explain in detail

Showing Answers 1 - 14 of 14 Answers

niranjan

  • Aug 8th, 2006
 

struts is a open source implementation of MVC design pattern to develop large scale web applications.Struts framework makes it easier to design realible,scalable web applications in java.Struts is not only thread safe but also thread dependent.It instantiates each action once and allows others to  be threaded through the original object.Struts reduces the for redundant jsp's.ActionForm stratagy reduces the need of sub class hierarchy.

Struts is a light weight package.It consists of 5 core packages and 5 tag lig directories. 

  Was this answer useful?  Yes

Jangam

  • Aug 14th, 2006
 

Struts Flow is a part of Apache Cocoon's Control Flow to Struts to allow complex workflow, like multi-form wizards, to be easily implemented using continuations-capable Javascript and eventually Java."

  Was this answer useful?  Yes

nitin

  • Aug 27th, 2006
 

all the above answers are can be fitted in the "what is struts?"

Struts is based on MVC architecuture. Flow of struts is as follows if my understanding of question is correct

1. request comes.

2. corrosponding action class will be searched in the struts.xml

3. mapped form-bean will be populated with data.

4. execute method of mapped action servlet will be executed and result will be mapped in struts.xml with <forward> tag.

5. mapped jsp/html page with forward will be displayed.

Pardeep Dureja

  • Sep 15th, 2006
 

Struts Flow Control starts from ActionServlet, on receiving request ActionServlet Delegate request to Request Processor, it is request processor that finds appropriate formbean on the basis of request,populate formbean, do required validation and execute app. action based on request.Hope this will solve ur quest...Pardeep Dureja

  Was this answer useful?  Yes

Sankar

  • Oct 15th, 2006
 

Hi,

If the client comes to the struts application then the flow of control will be..

1) The request received by hte ActionServlet which is the default Controller in Struts...

2)ActionServlet then call RequestProcesser.preProcess method to find the formbean,populate the value to it,validate the values..

3)Once the validating has finished,the ActionServlet's RequestProcesser.preProcess() method call Action class's execute method where the original business processing begins....

4)The action class process the method and reurns the result to ActionServlet.....

5)In returning the Action class provides the key to the corresponding ActionServlet to determine the reult acqiured fromprocessing will be diplayed...

6)The ActionServlet then display results to client using the key provided by the action class..

Hope You understand well..!!

Bye!

1. A request comes in with a .do extension, the container maps it to
the ActionServlet.
2. The ActionServlet acts like a front end controller and dispatches
control to a RequestProcessor.
3. The RequestProcessor finds an action tag with a path attribute that
matches the incoming request
4. Then the RequestProcessor looks for a form-bean tag that has a name
attribute that matched the action tags name attribute.
5. RequestProcessor instantiates a FormBean of the of based on the type
attribute
6. RequestProcessor calls populates the FormBeans fields from the
incoming request, then calls its reset method, then its validate method
7. RequestProcessor instantiates an Action based on the action tags
type attribute
8. RequestProcessor calls the action's execute method which returns
an ActionForward.
9. The RequestProcessor finds a matching ActionForward first within the
nested forward tags, then from within the global-forwards tag.
Note: if the validate method returns an ActionMessage then the
RequestProcessor forward the request to the resource specified in the
action's input attribute

  Was this answer useful?  Yes

 
Struts Flow
========

 
1) When application server gets started,container loads the web.xml

2) When first the request is made from a JSP/HTML/XSLT to the server with a particular URI(/something.do) the control first reaches Web.xml file.

3) It checks the mapping for /something.do in web.xml and finds the ActionServlet and loads ActionServlet.
......
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
.....

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

4) As part of loading ActionServlet calls the init() as every other servlet does.
(Note: ActionServlet extends HttpServlet only)
......................
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
........................

5) In init() it takes the init-parameters as struts-config.xml and loads the xml file.

6) Then the ActionServlet calls the process() method of RequestProcessor class.

7) process() method checks for the appropriate action in the action mapping for current request and maps the URI to the action in the struts-config.xml.

8) Then it creates an object to ActionForm associated to that action.

9) It then calls the setters and reset() methods in the form bean(Which extends ActionForm) corresponds to the mapped action.

10) If the action tag in struts-config.xml contains validate "true" then the validate method is called.

11) if any validation errors it return to view component (any jsp XSLT) which is specified as an attribute of input  "/error.jsp"

12) if there are no validation errors ,it then search for execute method in the action class and executes it.

13) execute method performs the bussinesslogic which you provide and returns with an ActionForward key.

14) Now the returned key is searched in the mapped action which is specified as forward tag.

15) It looks for the appropriate view component and performs the getters on that action form corresponding to this view component and loads the view page in the browser.

Hope it helps....

   
   - Prabhakar
 

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