Why Combine Servlets & JSP?
Typical picture: use JSP to make it easier to
develop and maintain the HTML content
For simple dynamic code, call servlet code from scripting
expressions
For moderately complex cases, use custom classes called
from scripting expressions
For more complicated cases, use beans and custom tags
But, that s not enough
For complex processing, JSP is awkward
Despite the convenience of separate classes, beans, and
custom tags, the assumption behind JSP is that a single
page gives a single basic look
103
JSP
www.corewebprogramming.com
Architecture
Approach
Original request is answered by a servlet
Servlet processes request data, does database lookup,
accesses business logic, etc.
Results are placed in beans
Request is forwarded to a JSP page to format result
Different JSP pages can be used to handle different types
of presentation
Terminology
Often called the Model View Controller architecture or
Model 2 approach to JSP
Formalized further with Apache Struts framework
See http://jakarta.apache.org/struts/
104
JSP
www.corewebprogramming.com
52