CS636 Practice Final Exam,     NAME:_________________________                                   

Open books, handouts, solutions, etc.

Show all work on these pages, using backs of pages if needed.  Points are marked in parentheses.  Total points = 150.

Note: the real final will have question(s) on Music3.

(40) 1.  Here are some coding rules that pa2’s solution followed, previously listed in the MidtermReviewOnLayers.  Recall that the pa2 solution was the final implementation of the client-server version of the music system. For each rule, consider if it is still true for the in-server implementations of pizza3 and music3, and mark it as follows:


Y  It fully holds for the in-server implementations (no justification needed, and true for many of these.)

E   It holds if an edit is done to the language of the rule (and give the edit or new version.)

N   It no longer holds (give the reason.)

Mark:___  Edit/Reason:  


Mark:___  Edit/Reason:  


Mark:___  Edit/Reason:  


Mark:___  Edit/Reason:  


Mark:___  Edit/Reason:  


Mark:___  Edit/Reason:  


Mark:___  Edit/Reason:  


Mark:___  Edit/Reason:  








(30) 2.  Suppose two students are ordering pizza at the same time, from different client systems, using an in-server implementation of the pizza system, that is,  pizza3.  At the moment, both student sessions are executing in the transaction that does the database insert.


a. Explain what data is held separately for each student:

i. in the session bean/ session variables



ii. in the BL (business layer)



iii. in the  DAO layer


b. Suppose at this moment an admin is setting a pizza ready, and has just started a transaction for this action, but it hasn’t yet changed anything in the database.  Thus there are two student sessions and one admin session in progress at this time. How many objects (0 is one answer) are there in the system in use for this app:

i. of class StudentBean or StudentBean1?

ii. of class StudentService?

iii. of class AdminService?

iv. of class PizzaSystemConfig?

v. of class EntityManager?

vi. of class EntityManagerFactory?

vi. of class HTTPSession?

vii. of class DataSource?



(20) 3.  We developed the service layer API for the pizza system originally while using the client-server architecture (pizza1/2).  We have been able to use the same API for the in-server implementation (pizza3).  Which of the following ideas (all true) best explains why this happened?  Discuss, explaining what a business layer API expresses, and assuming a layered architecture in both cases.

--both in-server and client-server architectures support multiple concurrent users

--transactions should not have user interactions within them, so the work of a database-backed application is subdivided by user interaction needs.

--we were using JDBC to access the database in both cases.




(30) 4. Consider the example in Murach, chap 7, illustrated p.205 (and studied in hw6), and provided in ch07cart. The user visits index.jsp for the first time, and clicks a button for 86 (the band), productCode 8601, causing the first execution of the servlet and display of cart.jsp. Then the user updates the order to quantity 3, causing a second execution of the servlet and second execution of cart.jsp. 

page flow







a. Write down the sequence of requests from the browser, starting from the one that first retrieves index.jsp. Assume that index.jsp and cart.jsp are in tomcat’s webapps/ch07cart directory in the deployed webapp.  The forms in index.jsp have action=”cart” method = “post”, and a hidden input field called “productCode”. The forms in cart.jsp have action=”” (could be action=”cart”)  method = “post”, and two hidden input fields called “productCode” and “quantity”. Show the full POST commands, ending with HTTP/1.1. Since the params don’t show in the command, list them as well (they would be encoded in the POST body)






b. Here the servlet executes in two separate request cycles. Explain how the the second execution has knowledge of the previous user choice of product “8601” with quantity = 1 in the first execution. 

(30)  5.  Consider the application scenario from the practice midterm. Suppose you are automating operations for a store selling PCs.   All PCs of a certain model number are equivalent as far as buyers are concerned, but the store wants to sell them in FIFO (first-in, first-out) order so that no box gets too worn-looking.  Each PC has a model number (int), serial number (10-char string), vendor id (int), and delivery date (int day number, when the PC arrived at the store.)  At sale-time, the salesperson will enter a model number and get back the serial number of the system to sell (in case of ties for oldest, any one of the oldest.)


  1. Write a business layer API that allows entry of new PCs by inventory clerks and retrieval of the next one to sell by salespeople.  Don’t forget the exceptions.





(eoneil note 12/17: replaced b. and c.--they were asking for Model 1 solutions, and we are not covering that approach)


  1. You are asked to write a web app for the salesperson to use. It has a form page with a form with method=”POST” action=”lookupPC.html” and an input text field with name “model” for the model number. It also has a result page found_pc.jsp, also in the top-level directory. Following our MVC webapp design, we would write a DispatcherServlet that handles the form submission. In its init() method, it calls the equivalent to PizzaSystemConfig.configureServices() and then calls to get a reference to your service API, and saves it in private static InventoryService inventoryService.  Write doPost() to handle the URL from the form submission, calling your API and forwarding to the result page. Don’t worry about errors here, and assume an appropriate web.xml. Use the back of the previous page.


  1. Write found_pc.jsp, using data you attached to the request object in DispatcherServlet.