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 is the difference between shocks and struts?

0 Answers  


Mark the differences between html tags and strut specific html tags.

0 Answers  


How struts control data flow?

0 Answers  


can we change the order of parameters in execute()?

4 Answers   Polaris, Serco,


Do you need an alignment after replacing struts?

0 Answers  






what is purpose cvs and vss in eclipse?

2 Answers  


What is the purpose of @customvalidator annotation?

0 Answers  


what happen if the private constructor is written in a claass

6 Answers  


1.Which of the following can be performed using interceptors by the developer? 1. Provide pre-processing logic before invoking the action 2. Interact with the action and set the request parameter on the action 3. Provide post-processing logic after invoking the action 4. Modify the result 1, 2, 3 2, 3, 4 1, 2, 4 1, 2, 3, 4 2.Interceptors can be used for which of the following tasks? 1. Checking security and bottleneck 2. Tracing the log 3. Validating user input 4. Uploading file 1, 2, 3 2, 3, 4 1, 2, 4 1, 2, 3, 4 3.The ValueStack is made up of which of the following objects? 1. Temporary Objects 2. Model Object 3. Action Object 4. Permanent Object 1, 2, 3 2, 3, 4 1, 2, 4 1, 2, 3, 4 4.Which of the following statements are correct? Apache Struts is a Java based framework that separates the application logic from the presentation layer. Action is based on pull-MVC framework which means that the data to be displayed is pulled from the action class which is a POJO class acting as a model in the Web application. OGNL is a powerful expression language that allows you to refer and manipulate the data present on the ValueStack. Declarative architecture enables you to integrate the different components present in the Web application either using XML files or Annotations. 5.Which of the following are the examples of helpers? 1. Action Interface 2. ActionSupport Class 3. ActionImplement Interface 1, 2 2, 3 1, 3 1, 2, 3 6.The Struts 2 filter performs which of the following tasks? 1. Installation of the Action class 2. Execution of the method specified in the configuration file 3. Reading of the control string 1, 2 2, 3 1, 3 1, 2, 3 7.Which of the following value for the debug parameter displays an OGNL console to test OGNL expressions against the value stack? xml console command All of the above. 8.Which of the following are correct statements? The execute () method of the action class defines business logic implementations. ActionSupport class adds useful utilities to the class that extends it. Set of Interceptors are grouped into a stack known as Interceptor Stack. All of the above. 9.Which of the following annotation helps to set the path of the action URL? It is placed before the action class and it applies to all actions defined in the class, even if the fully qualified URLs are not supplied. @Namespace @Result @Results @ParentPackage 10.Which of the following statements are correct related to OGNL and Annotations? OGNL is an expression and binding language that is used for getting and setting the properties of the Java objects. Annotations acts as an alternative to HTML and Java properties configuration file. Action Annotations are available when the framework scans the classpath for action classes. Lifecycle callback annotations are invoked at any time during the processing of an action. 11.Which of the following are the features of the new unified Expression Language? Deferred evaluation of expression Support expressions that can set values and invoke methods Provides a pluggable API for resolving expressions All of the above. 12.By introducing the new feature by JSF, improvements have been made in which of the following areas? Set of standard converter messages Addition of requiredMessage, converterMessage, and validatorMessage attribute for input components. Displaying the error message using the input component name with the help of label attribute added to the input components All of the above. 13.Which of the following statements are correct about the 'label' attribute? In JSF 2.1, the label attribute have been introduced with the input components. The label attribute can accept literal or value expressions. The Literal or value expressions accepted by label attribute is prefixed before the components error message. All of the above. 14.Which of the following statements are correct? EL allows developers to use simple expressions to dynamically access data from JavaBeans components. EL supports only deferred evaluation. A value expression can either yield a value or set a value and can be used for both read and write. In immediate evaluation, the expression is evaluated immediately. 15.Which of the following statements are correct? Method expression invokes as arbitrary private method of an arbitrary object by passing a specified set of parameters and returning results from the calling method. JSTL is a part of Java EE 5 platform. JSF 1.2 includes a set of messages for standard converters. The requiredMessage, converterMessage, or the validatorMessage attribute of the input components are used to provide custom error messages.

2 Answers   Wipro,


Can we handle exceptions in Struts programmatically?

0 Answers  


What do you mean by actionform?

0 Answers  


What is difference between struts1 and struts2?

0 Answers  


Categories