====== 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'' 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 by doing [[http://www.cse.yorku.ca/~roumani/warp/labs/lab4.pdf|Lab-4]]. * Read Chapter 6 up to and excluding Section 6.7. * Read Chapter 8 up to and excluding Section 8.5. * Look at the basic implementation of EVS in the //Resource Directory// under ''evs''. * Look at ''ELdemo.jspx'' and ''JSTLdemo.jspx'' in the //Resource Directory// under ''jsp''.