Skip to Content
Head First Servlets and JSP, 2nd Edition
book

Head First Servlets and JSP, 2nd Edition

by Bryan Basham, Kathy Sierra, Bert Bates
March 2008
Intermediate to advanced
911 pages
20h 31m
English
O'Reilly Media, Inc.
Content preview from Head First Servlets and JSP, 2nd Edition

Our very first pattern revisited... MVC

As luck would have it, the very same pattern we’ve been using in the book is on the exam. The last two patterns we’re covering are presentation tier patterns, as was the Intercepting Filter. First we’ll pick up where we left off talking about MVC. That discussion will lead us into Struts and finally Front Controller.

Where we left off...

Let’s do a quick review of where we left off in Chapter 2.

MODEL

Holds the real business logic and the state. In other words, it knows the rules for getting and updating state.

A Shopping Cart’s contents (and the rules for what to do with it) would be part of the Model in MVC.

It’s the only part of the application that talks to the database.

CONTROLLER

Takes user input from the request and figures out what it means to the model.

Tells the model to update itself, makes the model state available for the view (the JSP) and forwards to the JSP.

image with no caption

VIEW

Responsible for the presentation. It gets the state of the model from the Controller (although not directly; the Controller puts the model data in a place where the View can find it).

Note

Off Track: GUI MVC vs Web MVC

MVC existed before the World Wide Web came along. In its first incarnation, MVC was a design to simplify complex GUI applications. First created in Smalltalk, one of MVC’s chief attributes was that the View would be notified automatically of changes to the Model.

More ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Head First Java, 2nd Edition

Head First Java, 2nd Edition

Kathy Sierra, Bert Bates
Head First Java, 3rd Edition

Head First Java, 3rd Edition

Kathy Sierra, Bert Bates, Trisha Gee
Learning Java, 6th Edition

Learning Java, 6th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 9780596516680Errata PageSupplemental Content