Archive for Struts

MVC:Struts:Java - Web Application Development

Industries use frameworks for application development quite often.

For example: Java concepts like JSP, Servlet, Swing, Bean, JDBC can

be used directly to create web-applications but when such

applications become big, it becomes difficult to maintain and

develop them further. Hence, frameworks like struts are used to develop

large web-based Java applications. This makes maintenance and

further development easier. If you need to write a very simple web

application with a few pages, then you might consider using

JSP/Servlet directly otherwise Struts like frameworks are better

options.

Struts-1 uses the concept Model View Architecture (MVC) and provides

the controller. In MVC model, Model represents business logic, View
represents user interfaces, and Controller represents/controls control
flow of the application.

Struts' control layer is based on standard technologies like

Java Servlets, JavaBeans, ResourceBundles, and XML, as well as

various Apache Commons  packages, like BeanUtils and Chain of

Responsibility.

For the Model,  struts-1 framework can interact with standard
data access technologies, like JDBC  and EJB,  as well as most
any third-party packages, like Hibernate,  iBATIS,  or Object Relational
Bridge.  For the View,  the framework works well with JavaServer Pages,
including JSTL and JSF,  as well as  Velocity Templates,  XSLT,  and
other presentation systems.

The framework's Controller acts as a bridge between the application's Model and the web View.
When a request is received, the Controller invokes an Action  class. The Action class consults
with the Model to examine or update the application's state. The framework provides an ActionForm
class to help transfer data between Model and View.

Struts-1 Configuration
-----------------------
web.xml is one of the configuration files. It is an XML-formatted file that works as a
deployment descriptor.

struts-config.xml is another resource file to initialize the applications resources.
These resources include  ActionForms  to collect input from users,  ActionMappings
to direct input to server-side  Actions,  and ActionForwards to select output pages.

Sample struts-config.xml file.

?xml version="1.0" encoding="ISO-8859-1" ?>

Other resources like Validators can be initialized here.

Comments