Java
  Home arrow Java arrow Page 5 - Web Development in J2EE Using the MVC Desi...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Web Development in J2EE Using the MVC Design Pattern
By: Dwight Peltzer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 22
    2005-01-17

    Table of Contents:
  • Web Development in J2EE Using the MVC Design Pattern
  • Examining Servlets and Java Server Pages
  • Java Server Pages (JSPs) Resolve Servlet Issues
  • Applying the Model/View/Controller Design Pattern
  • Applying the Mediator Design Pattern

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Web Development in J2EE Using the MVC Design Pattern - Applying the Mediator Design Pattern


    (Page 5 of 5 )

    WebSphere architects have taken the MVC concept one step further by applying the Mediator design pattern introduced in Design Patterns by Erich Gamma. The Mediator/Controller pattern places another layer of indirection between the view and the model/domain. The Mediator/Controller captures and decouples application-specific functionality from presentation technology by implementing behavior usually existing as methods in presentation classes.

    The mediator can be better understood by viewing it as an abstract interface that must be implemented by providing a concrete mediator object. When a client submits a request, the mediator intercepts the request and delegates the task to a concrete class of objects to fulfill mediator/controller directed tasks. The mediator is also responsible for controlling and coordinating the interactions of groups of objects. As Gamma explains, “the Mediator serves as an intermediary that keeps objects in the group from referring to each other explicitly. The objects only know the mediator, thereby reducing the number of interconnections.” Doing so places behavior in one class, thus allowing the behavior to be modified or replaced locally. Abstract interface substitutability is the key to object reuse.

    Introducing the Front Controller Pattern

    The J2EE specification contains the “Front Controller Pattern,” a design pattern that defines how a Web tier controller should be implemented. It is located at “http://java.sun.com/blueprints/patterns/index.html.” It reads as follows: “The Front Controller pattern defines a single component that is responsible for processing application requests. A front controller centralizes functions such as view selection, security, and templating, and applies them consistently across all pages or views. Consequently, when the behavior of these functions needs to change, only a small part of the application needs to be modified.” This is precisely the methodology the Jakarta Struts framework uses. The framework is comprised of several classes/components. In addition, the framework organizes design patterns and provides a generic approach to designing Web applications.

    The Struts framework was created by Craig R. McClanahan in 2000. As previously demonstrated in the illustration, the Struts framework resides within the Web container component. This allows the Struts application to leverage the advantages of services provided by the container, i.e. managing requests via the HTTP and HTTPS protocols.

    The Struts Framework provides a modular framework from
    which you can develop your Web application. It is comprised of
    a controller servlet, numerous beans and classes, configuration
    files, and tag libraries. Let’s review some of the components the
    Framework supports:

    • Struts Tag Libraries
      • Bean Tag Library
      • HTML Tag Library
      • Logic Tag Library
      • Template Tag Library

    The Bean Tag library encapsulates tags needed to display static
    and dynamic Web pages. The tags are used to store and display
    data, write international type messages, and embed scriptlets for
    JSPs. Here is a list of tags included in the Bean Tag library:

    •  Define - Define new attributes and make them available at a pre-defined scope, i.e. request, page, session, or application scope.
    • Include - Include pages and fragments from other files in the current file’s source.
    • Internationalize requested messages from the Resource file and replacing the current tag with an appropriately internationalized message in any language.
    • Write - Write data from exposed beans at any level of scope.

    The HTML Tag library includes tags for all standard HTML controls. This library provides two important features: linking and internationalization. The tags are used to create page links in two formats: hyperlink or anchor.

    The Logic Tag library is directly responsible for basic first and second order logic functions utilized to portray JSP flow and functionality as well as the controls they provide, depending on the state of the form beans and input beans.

    The Template Tag library offers support for creating dynamic templates based on the JSP Framework for all pages sharing a common format. These are similar to style sheets or the standard include directive in JSP technology. They are dynamic. Here are three template tags:

    • Get - Retrieve content from a request scope bean.
    • Insert - Insert the retrieved content into the specified template.
    • Put - Create a request scope bean that specifies content used by the get tag.

    In order to bring all of these components together, we use a set of XML-configuration files to store mappings of different actions.

    Happy computing!

    Resources:

    Enterprise Java Programming with IBM WebSphere, Kyle Brown
    et al, IBM Press, 2003

    Building J2EE Applications with IBM WebSphere, Nillson and
    Mauget, Wiley, 2003

    Programming Jakarta Struts, Cavaness, O’Reilly, 2003

    Enterprise Java Programming with IBM WebSphere, Kyle Brown
    et al, Addison-Wesley, 2001

    Interoperability Between .NET & J2EE, Peltzer, McGraw-Hill/Osborne,
    2004

    Java Servlet Programming, Hunter & Crawford, O’Reilly, 2001

    Programming Borland JBuilder Developer’s Guide, Landy, Siddiqui,
    Swisher, et al., SAMS, 2003


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    JAVA ARTICLES

    - Deploying Multiple Java Applets as One
    - Deploying Java Applets
    - Understanding Deployment Frameworks
    - Database Programming in Java Using JDBC
    - Extension Interfaces and SAX
    - Entities, Handlers and SAX
    - Advanced SAX
    - Conversions and Java Print Streams
    - Formatters and Java Print Streams
    - Java Print Streams
    - Wildcards, Arrays, and Generics in Java
    - Wildcards and Generic Methods in Java
    - Finishing the Project: Java Web Development ...
    - Generics and Limitations in Java
    - Getting Started with Java Web Development in...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT