Name
Model-View-Controller
Also Known As
MVC, Model 2
Goal
Separate presentation tier into self-contained, reusable pieces (Figure A-5).
Participants
- Model
Stores application state data.
- Views
Stateless pages that transform model data into a form appropriate for display to the user, such as HTML, WAP or XML.
- Controllers
Process user input, update the model, and choose views (Figure A-6).
Figure A-6. Interactions in the MVC pattern
Interactions
The controller receives the user input, and translates it into appropriate updates to the model. The model applies business rules and stores the data persistently, either locally, in the business tier, or using some other remote persistence mechanism. Based on the model changes and user input, the controller chooses a view. The view transforms the updated model data into a form suitable for the user.
Notes
In J2EE, the model is typically implemented as JavaBeans or EJBs. The views may be JSPs, static HTML pages, or even servlets. The controller is usually a servlet.
Get J2EE Design Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.