FCI-Helwan blog

Just another FCI-H weblog

Learning Jakarta Struts Project


Struts

The Jakarta Struts Project

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

What is Struts?

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
presentation layer.

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 element.
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 element and this translated to java interface called ActionMapping.

Struts-Config.xml

· Three important elements in Struts-Config.xml
{form-bean, ActionMapping , global-forward }


To Be Continued….

Advertisements

October 12, 2008 - Posted by | JAVA

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: