But then his friend Kim takes a look

Kim comes in and says that while it IS an MVC design, it’s a dumb one. Sure, the business logic has been pulled out into a Model, and the servlets act as the Controllers working between the Models and Views so that the Models can be brain-dead about the Views. That’s all good. But look at all those little servlets.

What do they even do? Now that the business logic is safely tucked away in the Model, the servlet Controller isn’t doing much except some generic application stuff for this app, and, oh yeah, it does update the Model and then it kicks the View into gear.

But the worst part is that all that generic application logic is duplicated in every single frickin’ servlet! If one thing needs to change, it has to change everywhere. A maintenance train wreck waiting to happen.

“Yeah, I felt a little weird about the duplicate code,” says Bob, “but what else can I do? Surely you don’t mean for me to put everything in a single servlet again? How could that be good?”

image with no caption
image with no caption

Get Head First Servlets and JSP, 2nd 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.