Introduction to Web Application Technologies: Part IV

Model-View-Controller (MVC) Architecture in a Web Application:

  • Early in the evolution of graphical user interface (GUI) applications, a paradigm was developed that separated the three main concerns of the architecture of a GUI application.
  • The model is the conceptualization of the objects that the user is working with conceptually and the mapping of those concepts into the data structures: the user model and the data model.
  • An example of the user model is a paper document, which is represented as a structure of encoded text character in a word processor software data model.
  • The view is the presentation of the model data, also known as rendering. Typically this means generating a graphical display on a video monitor (though, technically, it can be rendered on any device that can be perceived by the user).
  • To manipulate the Model the users controls. The software that manages the user’s control events is the controller.
  • Typically the control consists of a series of events generated on a keyboard or a mouse, but more elaborate user interface devices can be used (technically input need not necessarily even come from a human being).
  • The controller is the logic that processes and responds to the users events. Based on the user’s input events, the controller typically sends change requests to the model.
  • The advantage of the MVC paradigm is an application architecture that separates the three concerns into separate software modules that communicate with each other using a relatively simple interface.
  • The advantage of separating those concerns has been coded that is much easier to test and debug because analysis can be focus on the interface between the modules and the source of the problems can be more readily isolated.
  •  Many years after its original conception, the MVC paradigm was applied to distributed web applications.

Note: Three tier architecture and MVC architecture are not the same. They are not even related concepts. Three tier architecture and MVC architecture are completely separate (orthogonal) concepts. Even the topology of each is different: three-tier is linear (layered) architecture; Model-View-Controller is triangular. The fundamental concept of three-tier architecture is that all communication passes through the middle ware tier. In MVC architecture the controller communicates with the model (and in some implementation with the view also), and the view obtains its data directly from the model.

  • The controller is typically used to process requests from client and forward requests for changes to the model. The view code accesses the model to render the HTML response to the client.
  • Traditionally, the view and controller reside strictly on a single middle ware server, while the Model API can be spread among several servers, including those in the data tier.

 

 

Web Application Technologies : Part IV

 

Model 2 Architecture:

  • In early web application design, the incoming request is handled by a JSP page or servlet, including processing the requesting, validating data, handling the business logic, and generating a response. The design is known as Model 1.
  • Model 2 facilitates proper separation of concerns using a variation on the MVC architecture. A web application designed using the Model 2 architecture has the following features:
  1. A servlet acts as the controller, which verifies from the data, updates the model with the form data, and does select the next view as the response.
  2. A JSP acts as the view. This renders the HTML response, retrieving data from the model necessary to generate the response, and provides HTNL forms to permits user interactions.
  3. JAVA technologies classes acts as the model, which implements the business logic of the web application.
  4. The figure given below shows the Model 2 architecture.

The combination of using servlet controllers and JSP page views provides the most advantages. The Model 2 architecture makes web application:

  • Fast
  • Powerful
  • Easy to create (for an accomplished Java technology developer)
  • Cross-platform
  • Scalable
  • Maintainable (supports separation of presentation and business logic)

Model 2 Framework:

  • Rather than trying to develop an entire Model 2 architecture from scratch, you might want to consider using a framework: a partial implementation which provides the core components and hooks onto which you can hang your customizations.

Some popular frameworks that you might consider if you are thinking of developing Model 2 architecture are:

  • Struts from the Jakarta project
  • JavaServer Faces technology from Sun
  • Velocity from Apache

Java EE Containers:

Web applications traditionally require implementing complex low-level details to perform some functions, such as:

  1. Transaction and state management
  2. Multithreading
  3. Resource pooling
  • The Java EE architecture is designed to help make web applications easier write because business logic is organized into reusable components.
  • In the tradition of Java SE, Java EE is also component-based and platform independent, so web applications written for one Java EE-complain platform should be easy to deploy on another vendors Java EE complaint platform.
  • The Java EE specification defines a set of containers that provide an interface for standard components of a web application.
  • The low level, platform specific functionality supports the component. Before a web enterprise bean or the application client component can be executed, it must be assembled into the Java EE module and deployed into its container.

Java EE containers include:

  • EJB container: Manages the execution of enterprise bean for Java EE applications. Enterprise beans and their container run on the Java EE server.
  • Web container: Manages the execution of JSP page and servlet components for Java EE components for Java EE applications. Web components and their container do run on the Java EE server.
  • Application client container: Manages the execution of application client components. An Application clients and their container run on the client.
  • Applet container: Manages the execution of applets. Consists of web browser, and Java plug-in running on the client together.

Sourabh Bhunje

Sourabh Bhunje, B.E. IT from Pune University. Currently Working at Techliebe. Professional Skills: Programming - Software & Mobile, Web & Graphic Design, Localization, Content Writing, Sub-Titling etc. http://techliebe.com/about-us

Leave a Reply