Controller class and JSP view dependencies

The corresponding controller classes can be found in the org.paulneve.wlab.webui package, and the tables below shows the correlations between the controller classes and the views. For the most part as a general guideline, *view.jsp is dependent on *Controller.java:

Student UI

JSP view(s) / controller classesPurpose and explanation
labconsoleview.jsp

LabConsoleController.java
Handles the student’s view of a lab exercise. Given a VM ID, the controller will build the appropriate parameters (e.g. IP address, screen size, etc) for the VNC applet. It also handles commands originating from the student via the JSP view, such as snapshot-related commands. Finally, it handles navigation to other stages of the lab exercise.
bookingview.jsp

BookingController.java
The view/controller to handle the session booking screen. Much of the actual functionality of this screen is provided by a combination of Javascript within the JSP page, plus AJAX calls to some of the viewless servlets.
wlab.jsp
studentlablist.jsp

WebUIController.java
wlab.jsp provides the initial login screen. The controller handles authentication. If unsuccessful, an appropriate message is passed to the view.

Once authentication is successful, if the user is a student, the controller then returns a ModelAndView object that includes studentlablist.jsp – essentially “switching” to this view. As part of the MaV object WebUIController will also supply any details of timeout countdowns, currently running bookings, status of the student’s VMs and so on. The view provides the student with commands to start/stop VMs – these however are handled by one of the various viewless servlets (discussed later).
vmconsoleview.jsp

VMConsoleController.java
This combination is never used unless you set the vmOnly flag in application-properties.xml. THIS SHOULD NEVER BE DONE. The configuration flag and these files are retained solely to show the evolution of the application through the iterative development process, for the purpose of an MSc dissertation. Almost certainly, after the completion of this MSc these files will be removed.

Tutor / Management UI

JSP view(s) / controller classesPurpose and explanation
backendvmlistview.jsp
BackendVmListController.java
This combination generates and displays a list of VMs from the virtualisation backend. In the JSP view, a tutor may choose to clone or edit the VMs (this will invoke the viewless servlet CreateNewBaseVm – discussed later).
backendvmmdview.jsp
BackendVmMDController.java
Provides the metadata page where a tutor can edit the basic details of a Tutor VM. In the UI, this is shown by clicking on the VM Details tab of editbasevmview.jsp and is embedded there via an IFRAME.
editbasevmview.jsp
EditVmConsoleController.java
The VM console view, used when a tutor is editing a Tutor VM. Works similarly to the student’s LabConsole view/controller combination, with options to navigate between stages removed.
labeditview.jsp
LabEditController.java
Provides facilities for a tutor to edit a lab. Much of the functionality comes via client-side Javascript.
lablistview.jsp
LabListController.java
Provides a list of labs so a tutor can select one to edit. Once one is selected, routes to labeditview.jsp. Also provides an option to create a new lab.
labstageeditview.jsp
LabStageEditController.java
Provides facilities for a tutor to edit a lab stage.
labstagelistview.jsp
LabStageListController.java
Provides a list of lab stages. When one is selected, routes to labstageeditview.jsp. Also provides an option to create a new lab stage.
studenteditview.jsp
StudentEditController.java
Provides facilities for a tutor to edit the basic details of a student. Additionally, the controller assembles and the view displays details of the student’s progress within the their labs.
studentlistview.jsp
StudentListController.java
Provides the list of students the tutor chooses for editing via studenteditview.jsp.
tutoreditview.jsp
TutorEditController.java
Provides facilities for a tutor to edit a tutor’s details. This is actually displayed embedded within the tutorlistview.jsp page via an IFRAME.
tutorlistview.jsp
TutorListController.java
Lists the tutors in the system, and provides links to edit or delete a tutor.
wlab.jsp
tutormenuview.jsp

WebUIController.java
TutorMenuController.java
As with students, wlab.jsp provides the initial login screen. The WebUIController handles authentication, attempt to authenticate first as a student then as a tutor. If unsuccessful, an appropriate message is passed to the view.

Once authentication is successful, if the user is a tutor, the controller then returns a ModelAndView object that includes tutormenuview.jsp – essentially “switching” to this view.

Viewless servlets

A number of “viewless” – i.e. they have no corresponding JSP page and do not use Spring MVC – are used for certain common backend tasks (e.g. starting/stopping VMs, etc). For consistency’s sake, they are configured in the web.xml configuration file to be accessible via a URL that ends in .html. They can be found in the org.paulneve.wlab.webui package, and are usually suffixed with *Servlet:

JSP view(s) / controller classesPurpose and explanation
BasicVMControlServlet.javaAccepts a command to start or suspend a VM, based on a supplied name. Note the name corresponds with the virtualisation backend, not with WLab’s own internal VM object names. This is used primarily by studentlablist.jsp to act upon commands to start or suspend labs.
CreateNewBaseVmServlet.javaWhen a tutor selects the Clone VM option to create a new Tutor VM from an existing VM, this servlet handles the cloning process and then sees the new VM through the appropriate number of reboot cycles in order to “make it safe” (see the Documentation for Tutors and Documentation for System Administrators). The new VM is created and started, then a new thread monitors the VM until it shuts down. When the thread detects a shutdown, it re-starts the VM, and then the thread terminates. Meanwhile, a redirect will already have been sent to editbasevmview.jsp/EditVmConsoleController.java. This controller checks for the existence of this monitoring thread to determine whether or not the new VM is ready for actual editing to take place. Once the thread no longer exists it knows the VM is ready, and establishes a VNC connection.

This servlet is also used when editing an existing Tutor VM which has previously been made safe – meaning that it will also need to go through the reboot cycles before it can be edited. In this instance, the process is identical, except that no new VM is actually created at the start of the process.
CreateNewStudentVmServlet.javaThis is called when a student attempts to access a Lab Stage that they do not yet have a StudentAllocatedVM for. A new VM is created from the Tutor VM, and the servlet sees the new VM through the boot cycle(s).

There are two modes. One is called with an AJAX request, and occurs when the student is actually running a lab console and attempts to navigate to a new stage. The code for this is found in labconsoleview.jsp and in this instance, the servlet itself “blocks” until the new VM is ready. Because the servlet was called via AJAX this does not impact the user experience. When the new VM is ready, the servlet unblocks and sends a success string, which in turn will fire the onreadystatechange event of the XMLHttpRequest object – in our case in labconsoleview.jsp, the Javascript function backFromCreate is called.

The other mode does not use AJAX, and occurs when the student selects the Create Lab option from their initial list of labs (studentlablist.jsp). This uses the same process as CreateBaseVmServlet.java where a thread is started to see the boot cycle through to its conclusion, a redirect is sent back to studentlablist.jsp, and the continued existence of the thread is used to determine whether or not the new VM is ready. When the thread ends, the VM can be used.
GetCourseDetailsServlet.javaSolely used via an AJAX call in labeeditview.jsp. Given a search parameter, if the servlet can find a course ID that matches, it returns the course name. If it finds a course name that matches, it returns the ID. Thus, the servlet is used to populate the course name in labeditview.jsp if the tutor fills out the course number, and vice versa.
LogoutServlet.javaDoes precisely what you’d expect, apart in one instance. If it finds both a tutor and a student in the session, it assumes that this is a tutor who has used the preview option to “simulate” the experience of a student. In this instance, the servlet clears the student from the session and redirect the tutor to their main menu. Otherwise, the session is invalidated and a redirect sent to wlab.html (which will display the login screen ready for a new login).
PreviewLabServlet.javaThis servlet is called when a tutor selects the preview option against a student (essentially, it allows them to assume the “identity” of a student and thus preview their labs from the student’s perspective). It simply accepts a student ID, then retrieves the appropriate student and adds them to the session. It then redirects to wlab.html which, if a student is in the session, bypasses the login screen and goes directly to studentlablist.jsp.
ToggleBookingServlet.javaThis servlet is called via AJAX when a student clicks a date/time slot on the booking form. If the supplied date/time has a booking already, it is cancelled. If not, one is added.
ToggleStageProgressServlet.javaThis servlet is called via AJAX from labconsoleview.jsp. Given a StageProgress ID, if the current status is InProgress it will be changed to Finished, and vice versa.