User Tools

Site Tools


jsp

This is an old revision of the document!


Table of Contents

MVC

This week applies MVC to the design and implementation of the Electronic Voting System of Labs 3 and 4. This includes writing servlets to control and dispatch, beans and POJOs 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> data structures to hold data with three levels of persistence: context, session, and request. A fourth level (available only to JSP servlets is the page).
  • 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: template code (such as HTML) which is served as-is, Expression Language [EL] which is served after evaluation, and special action tags which are served after executing the code behind them. It also support a few directives such as content type.
  • EL uses a number of built-in implicit objects.
  • Actions are either standard (JSTL) or custom.

To Do

  • Complete Labs 3 and 4.
  • 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 the basic implementation of EVS in the Resource Directory.
  • Look at ELdemo.jspx, JSTLdemo.jspx, and CUSTdemo in the Resource Directory.
jsp.1224603414.txt.gz · Last modified: 2008/10/21 15:36 by roumani

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki