The Jakarta Struts project, is an open−source project sponsored by the Apache Software Foundation. The Struts project was designed for creating Web applications that easily separate the presentation layer and allow it to be abstracted from the transaction/data Layers.
Model View Controller
Model : Represents the data objects. The Model is what is being manipulated and presented to the user.
View : Serves as the screen representation of the Model. It is the object that presents the current state of the data objects.
Controller : Defines the interaction between the view and the model .
The MVC (Model-View-Controller) model 2 :
all the views connect to one controller (Servlet) and this servlet works as a dispatcher where it handle all the requests and do whatever it needs in the business layer (Model).Struts is a web application framework to force
the user to follow the MVC models.
Struts don't cover the business layer at all (Model)
It concerned only with the controller.
Also Struts support a tag library for the
life Cycle :
Create new class for each transaction (will call it an action
this class extends Action Class(in Struts Api) and override execute() to handle the business login which this action will perform.
then add struts-config.xml and define each action with his properties in action
in web.xml we define the ActionServlet (provided by struts).
How Struts works
· When you Browse http://....../login.do
· The server check web.xml and found the servlet (ActionServlet)
· Then check the actions in struts-config.xml and found this action associated with specific action class.
· The action class Perform the code in execute() and return ActionForward
· ActionForward will give the result url
Struts Main Components:
ActionServlet : The role of the controller.
Action Mapping :
· tells the ActionServlet each request associated with specific Action.
· In Struts-Config.xml you type the
· Three important elements in Struts-Config.xml
To Be Continued….