What is Struts Flow?
Answers were Sorted based on User's Feedback
Answer / balachandar.s
Struts is based on MVC architecuture.
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.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / hemanthkumar
while making a call to index.jsp page straight
away request is not going to the ActionServlet, request is
going to the jsp page. Jsp page is giving output to the
browser. If request is not going to the ActionServlet Struts
framework is not at all involving.
Inside jsp page we have one <html:form> tag is
there. under <html:form> tag all custom tags are involving.
From this Custom tags all sequential methods can be
executed. After that it can execute action attribute, if
action attribute is .do request then it is mapped with
url-pattern of xml file.
while startup am application, ActionServlet
init() will be called because of load-on-startup tag in xml
file.
Struts developers developed ActionServlet and
kept inside struts.jar file.
While starting an application, ActionServlet
object got created and init() will be called. Inside body of
init(), it knows what is the config file and loads complete
content of the configuration file, and stored into the
ModuleConfig object.
Once app started conplete configuration can be
stored into the ModuleConfig object. It contains complete
configuration settings.
After that it will call init() of
RequestProcessor(RP) class. then the moduleconfig object is
going to the Rp.init().Now we have the availability of RP.
After that it will give a call to the form,
whenever we are calling form then formbean obj got created,
then it will look for scope, if scope is request then
formbean obj is stored into the request obj. All the getter
method's will be called for initialization purpose. Now,
once again it is going to the web.xml and call the
ActionServlet. Inside ActionServlet , it will call either
doGet() or doPost(). From this doGet(), it will call the
process() of RequestProcessor. Inside process(), it will
call processPreProcess().
If processPreprocess() returns false, the program
will be terminated.
If it returns true, then it will initialize the
ActionMapping object and call the validate().
If validate() returns error obj, then it will go to
the particular input field and display the errors. Otherwise
Action class object got initialized then execute() will be
called and execute the business logic. Finally interact with
the database....
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / nagaraja thummala
When the client send a request to container the container
will look for the ActionServlet, ActionServet will acting
like a controller,the configuration is their in the
web.xml, base on the web.xml ActionServlet will be
instatiated and initilized, after that ActionServlet will
take a cliend request and bipass the request to Request
processor, Request processor will find the struts-
config.xml and read the information about different modules
ActionServelet will call the Request processor process()
method. Request processor consists of chain of methods,
based on that it will create object for ActionForm and
validate the form fields and if validations are success
means it will create an object for Action class and call
the execute() and from the execute() it will commmunicate
with DAO and send the result page to view layer...
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / badhuman
Process flow:
web.xml : Whenever the container gets start up the first work it does is to check the web.xml file and determine what struts action Servlets exist. The container is responsible for mapping all the file request to the correct action Servlet.
A Request : This is the second step performed by the container after checking the web.xml file. In this the user submits a form within a browser and the request is intercepted by the controller.
The Controller : This is the heart of the container. Most Struts application will have only one controller that is ActionServlet which is responsible for directing several Actions. The controller determines what action is required and sends the information to be processed by an action Bean. The key advantage of having a controller is its ability to control the flow of logic through the highly controlled, centralized points.
struts.config.xml : Struts has a configuration file to store mappings of actions. By using this file there is no need to hard code the module which will be called within a component. The one more responsibility of the controller is to check the struts.config.xml file to determine which module to be called upon an action request. Struts only reads the struts.config.xml file upon start up.
Model : The model is basically a business logic part which takes the response from the user and stores the result for the duration of the process. This is a great place to perform the preprocessing of the data received from request. It is possible to reuse the same model for many page requests. Struts provides the ActionForm and the Action classes which can be extended to create the model objects.
View : The view in struts framework is mainly a jsp page which is responsible for producing the output to the user.
Struts tag libraries : These are struts components helps us to integrate the struts framework within the project's logic. These struts tag libraries are used within the JSP page. This means that the controller and the model part can't make use of the tag library but instead use the struts class library for strut process control.
Property file : It is used to store the messages that an object or page can use. Properties files can be used to store the titles and other string data. We can create many property files to handle different languages.
Business objects : It is the place where the rules of the actual project exists. These are the modules which just regulate the day- to- day site activities.
The Response : This is the output of the View JSP object.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / aadil rashid
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.
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.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / xxx
the following will make things more clear
http://dinu.blog.com/2010/11/28/struts-flow/
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / raj
when the application loads,container creates the instance of
the ActionServlet and call init() method . Init() method
load all the config files and required load parameter from
the web.xml file. Then the control goes to the particular
action class to the specified path and manipulate the logic
in model class and finally action class returns the response
to the specified jsp by using execute method.
Is This Answer Correct ? | 9 Yes | 18 No |
How Struts internally works? For Example if we type the URL "/login.do" how the process goes internaly? How the struts-config.xml loaded?
What is the use of struts config xml file?
How many struts config file can be created in struts?
in struts without integrate hibernate how to use directly explain?
What are the two scope types for formbeans?
State an example of struts configuration file as an action parameter for action servlet.
What are the steps used to setup dispatch action?
What are different Struts2 tags? How can we use them?
In which method of action class the business logic is executed?
1.when actionservelet execute. 2.when web.xml executes
Difference between JSF Framework and Struts Framework.
13 Answers Accenture, BSS, IBM, TCS,
What is actionservlet?