Demonstrate the Model-View-Controller design pattern that
can be implemented with JSPs and Servlets on the middle tier.
Remarks
This sample application demonstrates implementing the Model
View Controller (MVC) design for an application. This was formerly known as
the "Model 2" programming model in JSP specifications.
In the MVC approach, JSPs generate the presentation layer,
and either JSPs or Servlets perform process-intensive tasks. The front-end component
acts as the controller and is in charge of the request processing and business
logic.
In this sample, a controller JSP processes all requests.
After completing the processing, it forwards the request to appropriate JSPs
for presentation. The Controller is HotelReservation.jsp and the
JSPs used for presentation are HotelReservation.jsp, ReservationCart.jsp,
and Result.jsp.
The sample is an implementation of a Hotel Reservation Cart
where users can store reservation requests in a virtual shopping cart and submit
them in batch. All requests for the initial form, adding, deleting and submitting
of Reservations are submitted to the Controller JSP which processes the
request and finally forwards it to a JSP for presentation.
The inital JSP has a button to submit the form details which
calls the "Controller" JSP, which stores the request in a cart and calls the
same JSP again to display the Form along with the added reservation request(s)
in the cart. The list will be displayed along with two buttons to Submit or
Cancel. These requests will again be submitted to the Controller JSP to take
necessary actions. The Submit action involves storing the requests (in cart)
into the database, whereas the Cancel button just deletes all the requests from
the cart. The logic for performing database operations will be written in the
JavaBean. The JSPs in the sample form the "View" component.