Java
  Home arrow Java arrow Page 3 - J2EE Design Patterns: The Presentation Lay...
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 
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

J2EE Design Patterns: The Presentation Layer Patterns: Model-View-Controller
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2006-11-14

    Table of Contents:
  • J2EE Design Patterns: The Presentation Layer Patterns: Model-View-Controller
  • MVC: the Types
  • MVC in the Real World
  • MVC in the Real World continued

  • 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


    J2EE Design Patterns: The Presentation Layer Patterns: Model-View-Controller - MVC in the Real World


    (Page 3 of 4 )

    The application to be developed will have the following features:

    • First the user enters his or her first name, last name, and email address into a form which will be added to the list and reports whether the submission was successful.
    • If the submission was successful, the success page will be shown, or else the user will be redirected to the first page.

    The following are the files that will be used:

    1. subscribe.html -- provides the interface to enter user data.
    2. MailingBean.java -- a bean functioning as the Model.
    3. ListController.java -- the servlet that will be the Controller.
    4. redirect.jsp -- the View component that contains a part of the Controller logic.

    So first comes subscribe.html. It's a simple HTML file. It calls the Controller servlet.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN">

    <HTML>

      <HEAD>

        <TITLE>Subscribe!</TITLE>

      </HEAD>

      <BODY>

        <FORM action="/servlets/ListController" method="get">

            First Name: <INPUT type="text" name="first"> <br>

            Last Name: <INPUT type="text" name="last"> <br>

            Email Address: <INPUT type="text" name="email"> <br>

            <INPUT type="submit" name="Subscribe!">

        </FORM>

      </BODY>

    </HTML>

    Next is the Model. Since Models will be discussed in detail in coming parts, the actual implementation is left out for the present. It is an interface. Why it has been kept as an interface and how to implement it will be discussed in the future. It uses getters to retrieve the value and setters to place the value within the bean.

    public interface MailingBean {

        // first name

        public String getFirst(  );

        public void setFirst(String first);

        // last name

        public String getLast(  );

        public void setLast(String last);

        // email address

        public String getEmail(  );

        public void setEmail(String email);

        // business method

        public boolean doSubscribe(  );

        // subscription result

        public String getErrorString(  );

    }

    More Java Articles
    More By A.P.Rajshekhar


       · MVC is the most used design pattern. In this article I have discussed about MVC....
       · example wont run because there´s no implementation of bean
       · First thank you for your comment. Secondly, the reason Bean implementation has not...
     

    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-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek