J2EE Design Patterns: The Presentation Layer Patterns: Model-View-Controller
In any application, it is the presentation that matters most to the end user. The usability of software depends heavily on the User Interface or Presentation Layer in the case of J2EE. Since it is the Presentation Layer that presents the UI to the user, the solutions for recurring problems have to be standard. That is where Presentation Layer Design Patterns come into the picture.
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:
subscribe.html -- provides the interface to enter user data.
MailingBean.java -- a bean functioning as the Model.
ListController.java -- the servlet that will be the Controller.
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">
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.