Lab-4

    Servlets, Beans, and JSP


AN ELECTRONIC VOTING SYSTEM
Detailed Analysis

System Overview

A system to enable web-based election. When a voter visits our site, a login form is displayed. It prompts for the voter's SIN and PIN. If the login is accepted (see below) a voting form is displayed. It shows the names of all candidates and the party of each. When the user votes for a candidate the process ends. The design of the system, explored herein, adopts the Model II MVC design pattern.

Data Sources

We assume that two files are available: Voters, which contains the SIN/PIN pairs of all voters, and Candidates, which contains the name/party pairs of all candidates. Assume that these are CSV, Tab-Del, or XML files (up to you). These files should stored in WEB-INF so they are invisible to Coyote. Make sure you always use relative paths in your servlets so that your webapp is portable across servers.

The Model

The model is represented by the following components:

 

The Controller

One servlet controls the entire webapp. All output from this servlet is handled by a dispatching the request to a JSPX file; i.e. it never writes anything to its response parameter. Here are the controls:

The View

It is clear from the above that we need the following JSPX files:

The Result file must show, in a tabular fashion, the candidates, their parties, and the votes that each obtained as a raw number and as a percentage of the total. In addition, the report must indicate the turn-out and the time the report is generated. Finally, the row with the highest number of votes must be shown in red. If there is a tie, then the rows of all the winning candidates must be shown in green.