28-08-2012, 02:40 PM
Integrating Servletsand JSP: The MVC Architecture
Integrating Servletsand.ppt (Size: 930 KB / Downloads: 470)
Uses of JSP Constructs
Scripting elements calling servlet code directly
Scripting elements calling servlet code indirectly (by means of utility classes)
Beans
Custom tags
Servlet/JSP combo (MVC), with beans and possibly custom tags
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 elements
For slightly more complex applications, use custom classes called from scripting elements
For moderately complex applications, use beans and custom tags
But, that's not enough
For complex processing, starting with JSP is awkward
Despite the ease of separating the real code into separate classes, beans, and custom tags, the assumption behind JSP is that a single page gives a single basic look
Possibilities for Handling a Single Request
Servlet only
Output is a binary type. E.g.: an image
No output. E.g.: you are doing forwarding or redirection as in Search Engine example.
Format/layout of page is highly variable. E.g.: portal.
JSP only
Output is mostly character data. E.g.: HTML
Format/layout mostly fixed.
Combination
A single request will result in multiple substantially different-looking results.
Complicated data processing, but relatively fixed layout.
These apply to a single request
You still use both servlets and JSP within your overall application.