User Tools

Site Tools


mvc

Table of Contents

MVC

This lecture covers the MVC design pattern for web applications in the context of a mini-project. This includes writing servlets to control and dispatch, models to model the data and the business rules, and JSP pages to author the view.

Outline

  • The controller must control and dispatch by relying on the Model and forwarding to a JSP
  • Tomcat provides three Map<String,Object> places to hold data with three levels of scope: request, session, and application.
  • State can be captured using the session object. Its API allows us to detect the start of new sessions.
  • The model is best packaged as a Java package.
  • The model uses beans and POJOs. It is compiled (using javac) and tested outside Tomcat.
  • The servlet's init method is responsible for instantiating the model and storing it in the application scope.
  • Jasper translates a JSP page to a servlet upon receiving the first reference to it (typically from a servlet forward).
  • Jasper allows us to embed three things in the JSP page in addition to template (e.g. HTML) code: Expression Language EL, Directives, and Actions. These will be evaluated by Jasper and their values are served as part of the response.
  • EL uses a number of built-in, implicit objects.
  • Actions are either standard (JSTL) or custom.

To Do

  • Read the rest of Chapter 6.
  • Read Chapter 8 up to Section 8.4.1 but omit 8.3.2-8.3.3.
  • Look at ELdemo.jspx and JSTLdemo.jspx in the Resource Directory.
  • Do Lab-4.

Slides from Lecture

The Adobe Flash Plugin is needed to display this content.

mvc.txt · Last modified: 2008/08/29 19:09 by roumani