This tutorial provides you a better
understanding to develop a robust application
using Jakarta Struts Framework. Before starting
we are considering that you have an idea about
developing a web application by using JSP,
Servlets, JDBC and custom tags. So let’s from
the Jakarta Struts Framework.
Struts Frame is nothing but the implementation
of Model-View-Controller (MVC) design pattern.
Struts is an open source framework and
maintained as a part of Apache Jakarta project.
Struts Framework suits to develop any size of
application. You can down the latest version of
struts from http://jakarta.apache.org/. We are
using jakarta-struts-1.1 and jakarta-tomcat-
5.0.4 for this application. Before going to start
lets first take a brief introduction about MVC
Model-View-Controller (MVC) Architecture
Model-View-Controller architecture separates
the application components into three different
parts named Model, View and the Controller.
Each component of the MVC architecture is
independent with the other and also has unique
responsibility. Changes made to one component
have less or no impact on other component.
Here is description about the responsibilities of
the components of MVC architecture:
Model: This part of the MVC architecture
provides access to the data from the database
and also saves the data into the database. Model
includes the business logic of the application.
Model part also checks the Data send by the
user through View before saving it into the
database. Data access, Data validation and the
data saving logic are also part of Model.
View: View part of the MVC architecture handle
the view part of the application by taking the input from the user, dispatching the request to
the controller and receiving response from the
controller and displaying the result to the user.
HTML, JSPs, Custom Tag Libraries and
Resources files are used as part of view
Controller: Controller part controls the flow
of the entire application. It interacts with Model
and View and the works as Intermediary
between these two components of the MVC
architecture. Controller also receives the request
from client process that request by executing
the appropriate business logic of the Model and
then sends the response to the user using the
View component. Controller part includes
ActionServlet, Action, ActionForm and strutsconfig. xml as its parts.
Setting Up Development Environment
Before going to start first of all we have to
setup the development environment for the
Download JDK 1.4 or above from sun site.
Follow the instruction given in the installation
process to install JDK on your machine.
Download the binary version of Tomcat from
the apache site and follow the instruction to
install the tomcat on your machine. For this
application we have downloaded jakarta-tomcat-
5.0.4. After successfully completion of the
installation process test your installation. To test
the installation, go to your installation
directory/bin and issue startup command to
run the server. Open the browser and type http:/
/localhost:8080/ . If it is successfully installed
it should display the welcome page, If not
consult tomcat documentation before going
Installing Struts Application:
Download any version of Struts1 from the site
of Struts http://jakarta.apache.org/struts.
Extract file into the desired directory and then
copy struts-blank.war, struts
documentation.war and struts-example.war
directtory into “jakarta-tomcat- 5.0.4\webapps” directory.
struts-blank.war is a blank struts application
which is useful in creating struts application from
scratch. We are using this file to create our
Mar 2008 | Java Jazz Up |24
|View All Topics
|All Pages of this Issue