JSP Architecture
JSP Architecture
Outline
Model 1 Architecture
Model 2 Architecture
Model 1 architecture
JSP-Centric Architecture
– JavaBeans or EJB Model Objects
– View JSP pages
– Action JSP pages
Model 1 architecture
Model 1 architecture
Servlet-Centric Architecture
– JavaBeans or EJB Model Objects
– View JSP pages
– Servlet or Command Classes
Model-View-Controller
Request processing
Creation of any beans or objects used by the
presentation JSP
Deciding, depending on the user's actions, which
JSP to forward the request to.
Data validation
Controller Design
if (op.equals("createUser"))
{
model.createUser(request.getAttribute("user"),
request.getAttribute("pass"));
}
else if (op.equals("changeUserInfo")
{
// ... and so on...
}
Controller Design
String op = getOperation(req.getRequestURL());
Action action = (Action)actions.get(op);
Object result = null;
try {
result = action.perform(req);
} catch (NullPointerException npx) {
}
}
View Responsibilities
Server side
objects
Controller
Dispatch
Client
Action Tag libraries
and business
forward objects
JSP Page JSP page
include