O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

But then his friend says, “You ARE using MVC, right?”

Kim wants to know if the dating service can be accessed from a Swing GUI application. Bob says, “No, I hadn’t thought of that.” So Kim says, “Well, it’s not a problem because I’m sure you used MVC, so we can just whip up a Swing GUI client that can access the business logic classes.”

And Bob says, “Gulp.”

And Kim says, “Don’t tell me... you did not use MVC?”

And Bob says, “Well, I did separate out the presentation from the business logic...”

Kim says, “That’s a start... but let me guess... your business logic is all inside servlets!?”

Bob realizes, suddenly, why he went into management.

But he’s determined to do this right, so he asks Kim to give him a quick crash overview of MVC.

image with no caption

With MVC the business logic is not only separate from the presentation... it doesn’t even know that there IS a presentation.

The essence of MVC is that you separate the business logic from the presentation, but put something between them so that the business logic can stand on its own as a reusable Java class, and doesn’t have to know anything about the view.

Bob was partly there, by separating out the business logic from the presentation, but his business logic still has an intimate connection to the view. In other words, he mixed the business logic into a servlet, and that means he can’t reuse his business logic for some other kind of view (like a Swing GUI ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required