Using MVC in a Web Application

Most developers think of MVC in terms of a graphical user interface because MVC really came from GUI development. With a little imagination, however, you can extend the MVC paradigm to Web development, in terms of servlets and JSP. The idea is that you split your application into three sections. A servlet handles any requests from the browser and acts as a controller. You put your business logic (the model) in Java classes that are neither servlets nor Java Server Pages. Finally, you use Java Server Pages to display the view, a representation of the model.

When applying MVC to a Web application, you have to make some concessions toward the way the Web works. When you use MVC in a GUI application, you can display ...

Get Special Edition Using Java™ 2 Enterprise Edition 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.