Explain about struts control flow?

Questions by suri_veeru

Showing Answers 1 - 9 of 9 Answers

sivanand

  • Apr 5th, 2006
 

First when some data is submitted from jsp,the jsp engine will check for the action attribute in form tag in html page.it will then go to the xml file,there it will look in servletmapping element for the servlet name to which this attribute is associated with the based on this servlet name it will locate the corresponding servlet.from here onwards servlet will take the control of the whole application using struts config file.

  Was this answer useful?  Yes

jayakrishna

  • Apr 10th, 2006
 

when you deploy your struts application first step

1) the control moves to web.xml-their it picks up actionservlet which is present inside servlet tag and url of struts-config.xml present in the <int-param>

step 2

2)then it creates object for action servlet and checks the url from where the request came,if that url is same as url present in the path attribute of action tag then it picks up the value present inthe name attribute of action tag and searches in the formbean tag if the match is found then it creates object fr that form bean and calls the reset method and getters and it displays the jsp page in the browser to which you accessed.

step3

3)when you filled the details the page and enters the submit button, the formbeans will be called and setters and getters will be called and validate method will be called,if validation is success this method does not return any

error so the avtion calss will be called the execute method will be called

and excutes your business logic and it returns action forward

step4)

it checks inside the struts-conf.xml forward tag and control goes to that url present in the forward tag

if error happend in the validate method of action form than the url specified in the input tag will be called

  Was this answer useful?  Yes

Gopinath

  • Apr 18th, 2006
 

Having received the request the ActionServlet locates the correct Form Bean from the struts-config.xml. The ActionServlet invokes the FormBean Validator logic.If the Form Bean finds any error,it populates the ActionError Object

Using the Struts-Config.xml the ActionServlet locates and invokes the Action Class which invokes the model and returns an ActionForward object to the ActionServlet.

The ActionServlet uses the ActionForward Object to dispatch to the correct view component 

  Was this answer useful?  Yes

parindia

  • May 4th, 2006
 

1) when a user submitted a jsp page. that page having (attribute of )action="login.do". the container will call to WEB.XML. in that web.xml thert is two section servlet And servlet mapping2) in servlet mapping it fine *.do in the url-pattern. if it found to take the name of servlet. and check the corresponding class. in the servlet section. that class is ActionServlet. 3) ActionServlet is the controller of Struts module architecture. in Action servlet having the service method. in thatr method we create RequestPrecessor class instance 4) service(req,res)RequestPrecessor rp = new RequestPrecessor();5) we call a process method of RequestProcessor class through the instance rp.process(req,res)6) in the request process class have the process method with the parameter of req,res. then it have 1 if condition in this class. that condition return always true. because that is dummy method.7) inside that condition ther is 6 steps are processing a)create a action mapping instance in the "Struts-Config.Xml". it will kept all details of the action mapping path, value, type forward, validation=true/false, input ="*.jsp" etc these r created instance b) then it will crate form class instance before it check the name of action mapping and form name are coincidence or not if it same it will create form instance c) then it will go to actionmapping instace the ris mention or not the validate =true/fale if false it will not execute the this step else it will execute this step. d) then it will create action instance e) next it will taken four parameters of execute Method it will return ActionErrors instance. if it is not empty. it will go to error page other wise it will got to corresponding page. else if it is empty if will go further and display corresponding value of page in jsp viewthis is struts flow if ther is any error in my process pls letu know me dont forget guys thank u

  Was this answer useful?  Yes

santhosh

  • May 21st, 2006
 

RE: Explain about MVC-2 ARCHITECHTURE IN STRUTS control flow?

  Was this answer useful?  Yes

niranjan

  • Aug 8th, 2006
 

Struts follows the MVC design pattern along with the help of ActionMappings and ActionForwards to control the data flow.

  Was this answer useful?  Yes

vadamalaiganesh

  • Jun 5th, 2007
 

Hi,
    The explanation given by parindia is crystal clear But not Formatted thatt why looks messy,I have formatted it,Wonderful parindia ,You are really expert.


 

1) When a user submitted a jsp page. that page having (attribute of )action="login.do". the container will call to WEB.XML. in that web.xml thert is two section servlet And servlet mapping



2) In servlet mapping it find *.do in the url-pattern. if it found to take the name of servlet. and check the corresponding class. in the servlet section. that class is ActionServlet.


3) ActionServlet is the controller of Struts module architecture. in Action servlet having the service method. in that method we create RequestPrecessor class instance


4) Service(req,res)

RequestPrecessor rp = new RequestPrecessor();


5) We call a process method of RequestProcessor class through the instance rp.process(req,res)


6) In the request processor class have the process method with the parameter of req,res. then it has 1 if condition in this class. that condition return always true. because that is dummy method.


7)Inside that condition ther is 6 steps are processing


a)Create a action mapping instance in the "Struts-Config.xml". it will kept all details of the action mapping path, value, type forward, validation=true/false, input ="*.jsp" etc these r created instance


b)Then it will create Form class instance before it check the name of action mapping and form name are coincidence or not if it same it will create form instance


c)Then it will go to ActionMapping instace the ris mention or not the validate =true/fale if false it will not execute the this step else it will execute this step.


d) Then it will create action instance


e) Next it will take four parameters of execute Method it will return ActionErrors instance. if it is not empty. it will go to error page other wise it will got to corresponding page. else if it is empty if will go further and display corresponding value of page in jsp view.This is struts flow.

  Was this answer useful?  Yes

laxman

  • Dec 11th, 2012
 

I think there is no service method in ActionServlet class it inherit it from httpServlet class but again I dont see any
call to process method of RequestProcessor ?

  Was this answer useful?  Yes

simhachalam

  • Oct 15th, 2014
 

Hi Friends,The actual struts flow will be like this.1)user sends a request from front-end.2)Reading the form action and went into web.xml ,from the control went to front-controller (ActionServlet) in this actionservlet class reading the init parameters which is mapped in tag contains struts-config.xml in web.xml,3) Reading all configuration which is mapped in struts-config.xml and stored inside the moduleconfig object which is extracted in to RequestProcess Object.3) from here the actual struts life is starting..in this total 4 stages are i)ActionMapping,ii)ActionForm,iii)Action,iv)ActionForward.

i) ActionMapping: reading all configuration information will be taking and kept inside.
ii) ActionForm: Reading all the bean class information and also execute validate method,if validate method returns any ActionErrors object from there the struts slow will be breaks and get back to front end page.If no ActionErrors object the from will be reached to iii & iv steps.
iii) Action : In this Action it executes the execute(-,-,-,-) method of Action class which is having the return type ActionForward. with this return type we are sending a key to the destination page like return map.findForward("SUCESS");
iv) ActionForward: In the actionForwardObject having findForward() method from there forwarding the request to jsp page which is mapping with the key name.

  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