How to explain struts work flow

Answers were Sorted based on User's Feedback



How to explain struts work flow..

Answer / madhu

1) A request comes in from a Java Server Page into the
ActionServlet.
2) The ActionServlet having already read the
struts-config.xml file, knows which form bean
relates to this JSP, and delegates work to the validate
method of that form bean.
3) The form bean performs the validate method to determine
if all required fields have been entered, and performs
whatever other types of field validations that need to be
performed.
4) If any required field has not been entered, or any field
does not pass validation, the form bean generates
ActionErrors, and after checking all fields returns back to
the ActionServlet.
5) The ActionServlet checks the ActionErrors that were
returned from the form bean’s validate method to determine
if any errors have occurred. If errors have occurred, it
returns to the originating JSP displaying the appropriate
errors.
6) If no errors occurred in the validate method of the form
bean, the ActionServlet passes control to the appropriate
Action class.
7) The Action class performs any necessary business logic,
and then forwards to the next appropriate action (probably
another JSP).

Is This Answer Correct ?    167 Yes 14 No

How to explain struts work flow..

Answer / pradeep kumar simhadri

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.

Is This Answer Correct ?    80 Yes 11 No

How to explain struts work flow..

Answer / mahmood alam siddiqui

Struts work flow:
When user run the Struts Application
first of all controll goes in XML file and find the Action
Servlet that is main controller class in Struts after that
control goes in Struts-config.xml and find the Action, find
the Form bean and execute the action if method execute
successfully the forward the output at given JSP.

Is This Answer Correct ?    101 Yes 36 No

How to explain struts work flow..

Answer / aleem

when client makes the request,the request goes to web.xml
files <url-pattern> tag from here it goes to <servlet> tags
<servlet-class> there ActionServlet is loaded into the jvm,
and it is instantiated,initialized with in its init method,
Now the responsibility of actionServlet is to identify the
request processor,by using <inti-param> tag,after request
processor identified ,ActionServlet creates the instance of
the request processor,on that instance of request processor
calls the process(), as a result request reaches to the
requestprocessor.
the next responsibility of requestprocessor is to identify
the Action,using the client requestd uri.if client requested
uri and struts-config's path attributes are same then it
checks for the name attribute,if name attribute is found the
it goes to the <form-bean>tag there it check,if found ,sees
whether the form bean instance is available in the request
scope or not ,if found it instance set the request parameter
values by calling setxxx methods.then request reaches to the
Action. action returns the ActionForward object, using which
<forward> tag forwards to the appropriate jsp.

Is This Answer Correct ?    43 Yes 11 No

How to explain struts work flow..

Answer / karthick prabu.v

1) when the client send a request first it will goes to the
web.xml file.
2) there it will check the ActionServlet class(contoller).
3)From there it goes to the struts config.xml file
4)in the config.xml file it checks the form bean class and
execute class
5) then the controll goes to the model class.(Action class).
6)execute the logic in the action class.
7) after completion of the execution it send some response
to the controller.
8)then the controller goes to the config.xml file and checks
the where the controller have to go.
9)again it come back to the controller and goes to the
related jsp file.
10)there the jsp file execute and give the out put to the
browser.

Is This Answer Correct ?    23 Yes 6 No

How to explain struts work flow..

Answer / jayachender

When we send the request the follwing actions will be perform.
1.The Server Searches for Deployment-Descriptor(web.xml)
2.If the server Found <load-on-startup> tag the server will create the required Servelet Object.
3.After Servlet object is created the server will execute the init() method of ActionServlet.
4.As part of init method of ActionServlet finds the value of Config init parameter.
5.The init() method start reading contents from the struts-config.xml(Struts Configuration file) and store the information in jvm's Memorey

Is This Answer Correct ?    21 Yes 8 No

How to explain struts work flow..

Answer / mairaj

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..!!

Is This Answer Correct ?    16 Yes 10 No

How to explain struts work flow..

Answer / bhoorgu rakesh

1.Browser sends the request to uor Container ,container Communicate with web.xml for wich url matches that container forward url to actionServlet
2.Action servlet search wich sub control invoke by using struts-config.xml
3.Action servlet assign form data to ActionForm to create form object
4.ActionServlet gives ActionClasss wich execute()
5.action class connect to model execute BusinessLogic
6.Model class connect util class to establish connections
7.model communicate with the DataBase
8.DataBase gives to model if any logic is their ,then execute that logi
9.moddel communicate with the ActionClass
10.ActionClass communicate with the Memory
11.ActionClass send the logical jsp name to ActionServlet
ActionServlet takes that logical jspname search in the struts-config.xml to call exactly jsp
12.ActionServlet call extacly jspname
13.View communicate with the Memory
14.view page sends the response to Browser

Is This Answer Correct ?    7 Yes 2 No

How to explain struts work flow..

Answer / shiva

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

Is This Answer Correct ?    4 Yes 1 No

How to explain struts work flow..

Answer / manu

client send the request to the server,
after that the struts internal code will take care of
everything......y do we suffer?
this is called struts flow

Is This Answer Correct ?    9 Yes 17 No

Post New Answer

More Struts Interview Questions

What do you mean by dynaactionform?

0 Answers  


In Struts Programming which is the controller,which is the model?

10 Answers  


Which library is provided by struts for form elements like check boxes, text boxes etc?

0 Answers  


Which design pattern is implemented by Struts2 interceptors?

0 Answers  


What do you mean by a custom tag?

0 Answers  






What is struts and why it is used?

0 Answers  


Explain the difference between jakarta struts and apache struts?

0 Answers  


Does apache struts run on windows?

0 Answers  


which MVC architecture struts follows and why?

6 Answers   IBM,


How do you know what to give for the "path " under in struts-config.xml ?

1 Answers  


How nested beans can be used in Struts applications?

0 Answers  


Is struts thread safe?

4 Answers   HCL, Mphasis,


Categories