JavaServer Pages
Servlets
are notoriously clumsy at constructing HTML documents through
Java code. JavaServer Pages (JSP) are text documents that contain static and
dynamic content through the use of tags and a unified expression language (EL).
JSPs are compiled into Servlets and have implicit access to the request and
response objects.
Servlets
and JSPs frequently work together through
a RequestDispatcher. A RequestDispatcher transfers control
of a request from one resource to another. For example, a servlet typically
handles the logic for a request and delegates to a JSP to render the response.
Filters
Filters
intercept servlet requests to provide cross-cutting functionality.
For example, a security filter could redirect unauthenticated users to a login
page. Filters are mapped to URL patterns in the deployment descriptor.
Model-View-Controller
Model-view-controller (MVC) is a design pattern that encourages the separation
of concerns in a web application. The model represents domain objects, such as
data retrieved from a database. The view is a visualization of the model, such as
a JSP that constructs an HTML document. The controller facilitates changes
to the model, such as a Servlet that handles the submission of a form.
Multiple frameworks exist to facilitate the MVC pattern, such as Spring MVC.
Questions
What is a servlet container?
What is a web application?
What is a WAR file?
What is a web.xml file?
What is the difference between a Servlet and an HttpServlet?
What is the difference between a Servlet and a JSP?
What is a servlet filter?
What is the model-view-controller pattern?
|