CS636 Programming Assignment 2 (pa2)

Music3, a DB-backed Spring Boot/Maven WebApp

You will design and implement a multiple-JSP-page UI for the music project, following the general UI flow specified in Murach originally, and simplified as shown in the Music UI page flow diagram. Tie the two UIs together (as in pizza3) by having a home page for the whole system with the simple choice of User or Admin services (this is provided). Don't break the old client-server apps or the unit tests!

As in pizza3, we will use JSP for display, but locate all the decision-making and calls to the service layer in Java.. In each request, the handler is in Java and uses @RequestMapping (or one of its specializations like GetMapping), and usually forwards to the view, in JSP. In some cases the handler code forwards back to another handler, using its endpoint URL. Following MVC, the JSPs to do pure display of previously determined data, that is, the JSPs must not access the database or take user input. Also, the JSPs should have no scriptlets or Javascript.

Use pizza3's StudentController as a model for the UserController, which is partially implemented as provided. Where useful, one handler of the controller can forward requests to another handler. For example, in StudentController, after the student "receives" the order,  the receivePizza handler forwards to the student-welcome handler, so it doesn't itself have to read the database for all the data needed by the student-welcome page.

The servlet code in Murach’s musicStore project (online (zip)) should be a big help in writing the controllers, for example, the CatalogController servlet of pg. 653 can become parts of UserController with a few edits. However, note the lack of a service layer and use of static methods for the DAOs, so proceed with care. Don't use all those JSP include files in Murach's MusicStore. As in pizza3, you can use header.jsp, footer.jsp and sidebar.jsp if you want, but no more includes than that, and these are optional. You can use snippets of JSP from the musicStoreJPA in your own JSPs. 

You may use session beans called UserBean (provided) to follow the user through their pages, or use multiple session variables, but note that UserBean is provided and already in use.  In the JSP code, use JSTL/EL for all dynamic HTML. Don't use JSP to get user input from request parameters: use the controllers as in pizza3. 

We need the capability of listening to the samples listed in table track. You may write a single page that displays tracks for any CD using track table data, something like the Sound page, pg. 652 and partially implemented in file sound.jsp. It's OK to list only the tracks in the track table. Alternatively, use the sound/*/sound.html files of music3-setup. Note the download app ch07downloadS (zip) is available and plays the samples, showing how to get the browser to play the mp3s (preferably using the HTML5 audio element). The provided files assume you use the track table to generate the mp3 file names, but this is not required. 

Technologies: we are using Java, HTML, JSP, EL, JSTL, servlets, Spring Boot controllers, Spring beans, Spring-supported DataSource, and optionally, simple CSS. Maven for building. Projects should not use Javascript, or any software system that requires additional jar files.

Suggested steps for getting started on pa2: 
1. Get pizza3 working, for reference. Do homework 5.
2. Start from music3-setup.  Install 2 copies, one as music3-setup and another as music3 for development.
3. Try running the provided project as described above.
4. Study StudentController from pizza3 and the provided AdminController. Decide on one action, say displaying the catalog page, and put code in the UserController for that.
5. Use one of the provided stub JSP pages, say catalog.jsp, first without added dynamic HTML, and see it displayed using the URL you returned from the handler.

pa2 Delivery:
Sunday, May 9:
Final version of pa2, in the cs636/pa2 directory.  Late days can be used (max 2 days).
Use the packages and directories as in the supplied music3-setup project, and corresponding to pizza3:

cs636/pa2: base directory of project
README: notes to grader, i.e. cs636/pa2/README
pom.xml, *.cmd, *.sh  same as provided
cs636/pa2/database/build.xml, createdb.sql, etc.: same as provided.
cs636/pa2/src: top of sources tree
src/main/resources: as provided, with server.port 5xxx3, your pe07 music3 port (see CS636Ports.html)
src/main/test: as provided
src/main/java:
cs636.music.config: provided
cs636.music.presentation: any sources common to web and client-server presentation, including SBApplication and SystemTest: provided but can be changed.
cs636.music.presentation.clientserver:  AdminApp, UserApp (same as provided) 
cs636.music.presentation.web: SysTestServlet, AdminController, UserController, optionally *Bean, CartDetails      
cs636.music.domain: same as provided
cs636.music.service: same as provided
cs636.music.service.data: same as provided
cs636.music.dao: same as provided

webapp:
includes: nothing provided, but put header/footer/sidebar JSPs here if desired, but not more than that
sound: provided mp3 files and related html
styles: nothing provided, but put CSS here if desired (keep it simple, or like pizza3's)
WEB-INF/jsp/*.jsp   user pages, hidden from direct access from web by being in WEB-INF
WEB-INF/admin/*.jsp admin pages (provided), similarly hidden

The main grading execution test will look like this, using pe07.cs.umb.edu: reload DB for all 3 DBs, run SystemTest as client and via its servlet using multiple DBs, run the web case. We will try out the JSPs too as well as read them, or use the browser automation tool “Selenium”. Be sure that all the provided commands in the base directory will work on pe07 for our standard environment variable settings, since this grading execution will not be using your environment variable settings. The sources (java and jsp) will be read for good programming practices and decent header comments (Javadoc optional) on classes and public methods.