life cycle of struts?

Answer Posted / vikram naidu

When any struts based web application loaded into server
initially it will load the ActionServlet class, due to
<load-on-startup> tag in web.xml. After instantiation it
will read struts-config.xml file, due to <init-param> tag in
web.xml. When anybody makes request to the respective web
application it will display the file which is mentioned in
<welcome-file-list> tag of web.xml file. When the view
page(.jsp) is displayed to the user internally the struts
framework (ActionServlet) will create an object for the form
bean class (which extends the ActionForm by calling zero
argument constructor(default construtor)) which is mapped
with the Action class path mentioned in .jsp file <html:form
action="/path"> b'coz ActionServlet already read the
information mentioned in struts-config.xml file. later it
will call the reset() and all the getter methods of the form
bean class. when the user fills the form and submit the
input, our form bean class again calls the default
constructor, reset(), all setter() methods, validate()
methods respectively. Validate method return ActionErrors
object. If the ActionErrors object contains any error
values(ActionError/ActionMessage values) then the
ActionServlet calls the input page mapped with respective
action class(<action input="/input.jps") that page will
display to the user with error messages. If ActionErrors
object is null(doesn't contains any ActionError/
ActionMessage) then the ActionServlet calls the execute()
method of the Action class which is bind with input request
(<action path="/path" type="package.OurActionClass"). the
execute() method will return ActionForward object. Depend on
the value, again the ActionServlet will call the respective
view(.jps page) as response and send it back to user. For
processing all the above steps ActionServlet will take the
help with RequestProcessor class. In this way one request
will be processed by the struts framework. And ActionServlet
will act as a front controllet for the application.

Is This Answer Correct ?    27 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do I have to credit struts on my own website?

537


What are the features of struts?

578


What is the difference between plain-validator and field-validator?

526


Explain the difference between jakarta struts and apache struts?

531


Why struts 1 classes are not thread safe whereas struts 2 classes are thread safe?

505






What is the apache struts vulnerability?

525


Which class of struts is responsible to converts data types from string and vice versa?

668


What is the use of reset method of ActionForm class?

575


What is the actionform?

580


What is the purpose of @results?

587


What is declarative exception handling in struts?

561


Explain about logic match tag?

575


Does apache tomcat use struts?

512


What is jakarta struts framework?

568


How many Action classes have been used in your project? Differences between struts 1.1 and 1.3?

2537