Professional Documents
Culture Documents
University of Mauritius: Faculty of Information, Communication and Digital Technologies
University of Mauritius: Faculty of Information, Communication and Digital Technologies
MAY 2018
INSTRUCTIONS TO CANDIDATES
Question 1
(a) In the Java Enterprise Edition (Java EE) multi-tiered application, the functionality of
the application is separated into isolated functional areas, called tiers: Client, Middle
and Data.
(i) Briefly explain why a multi-tier architecture is better than a 2-tier architecture.
[3 Marks]
(b) Your services have been sought for the development of a Monthly Tax Calculator to
be used by the Finance Section to determine the monthly tax amount for each
employee. The system is illustrated in Figure 1. The user enters the monthly salary
of the employee and his/her category. The different categories are shown in Table 1,
together with the respective threshold amount. The monthly tax is then calculated as
follows:
Tax = 0.15 x ((13 x monthly salary) – threshold)
12
Figure 1
(continued next page)
Page 1 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT
[7 marks]
(ii) The index.jsp page (Figure 1) uses the stateless session bean, TaxCalculator,
implemented in part (i) to compute and display the threshold and the tax
payable on the same page. Implement the JSP page, index.jsp. You may
disregard the tabular arrangement of the page.
[8 marks]
(Total: 25 marks)
Question 2
(a) The Java EE platform supports a number of authentication mechanisms. Briefly
describe two such authentication mechanisms.
[3 marks]
(b) The availability of an Enterprise JavaBean for use in a JSP application is defined
as the scope of that bean. There exist four different scopes for an Enterprise
JavaBean. Differentiate between these four possible scopes.
[4 marks]
(c) Your friend, the owner of a small business MauLaptop which deals in IT
equipment, is seeking your help for the development of an Online System (OS)
that will enable him to manage his stock of laptops. You decided to create an
online system based on PostgreSQL and JSP. Details that need to be kept about
the laptops in the Laptop table are:
Model (e.g. HP Pavilion)
Price (e.g. 28000.00)
Storage-GB (e.g. 1000)
RAM-GB (e.g. 16)
Quantity (e.g. 25)
(continued next page)
Page 2 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT
(i) Create an entity bean, Laptop.java, that you would use to act as an
intermediary between the online application and the PostgreSQL database.
[5 marks]
(ii) You create the following page (Figure 2) that is used to search for existing
laptops.
Figure 2 – view.jsp
The Online System consists of a Manager class, LaptopManager.java that implements the
related CRUD functions.
Assuming that the:
name of the database is OS and is hosted on localhost,
table name is laptop and its primary key is model,
the login is guest and password is guest,
field names of the laptop table are the same as the attributes of your above
Laptop Entity bean,
Give your implementation of the method findLaptop. Its signature is given below:
(iii) Give your implementation of view.jsp. The message “Laptop NOT found” is
displayed in the case the model cannot be found in the database. You may
disregard the tabular arrangement of the page.
[6 marks]
(Total: 25 marks)
(continued next page)
Page 3 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT
Question 3
(a) Briefly describe and differentiate between traditional IT and the three different types
of Cloud Computing services: Software as a Service (SaaS), Platform as a Service
(PaaS) and Infrastructure as a Service (IaaS).
[4 marks]
(b) By using suitable examples, compare and contrast Manual Validation and Explicit
Automatic Validation as supported by JavaServer Faces.
[4 marks]
(c) As expected, the UoM Students Union will be organising its end of academic year
party in June. They have contacted you to develop a system that can help them in
the sale of foodstuff on this occasion. You propose the following responsive JSF
application (Figure 3) which uses the PrimeFaces component library.
Figure 3 – eoy.xhtml
Page 4 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT
The Students Union has requested you to use the below pricing policy for
implementing the application.
Optionally and against additional payment, there are top ups that may be added to
the meal, as shown in the table below. The same prices are applicable for both
students and staff.
Top Up Price (Rs)
Chicken 40
Eggs 30
Prawns 50
(i) Implement the Managed Bean Pricing.java which is the backbone of the above page.
You may skip the getters and setters for the class.
[7 marks]
(ii) Give your implementation of eoy.xhtml. The page uses AJAX to allow it to be
responsive. You may disregard the tabular arrangement of the page.
[10 marks]
(Total: 25 Marks)
Page 5 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT
Question 4
The Faculty is embarking on a new initiative to reward brilliant full-time students (aged
between 18 and 25 inclusive) who have a CPA between 70 and 100 inclusive by
publishing the yearly Dean’s Merit List. Your help is required to help to create the
Dean’s Merit list using Hibernate and Data Table technologies. The Dean also requires
that the application implements necessary validations to ensure that the list is accurate.
E.g. a valid student is a 7-digit number as shown below. A design of the proposed
system, meritoriousStudents.jsp, is given in Figure 4.
Figure 4 – meritoriousStudents.jsp
The above proposal uses manual validations whereby error messages, if any, appear in
the footer of the data table. The system uses a managed bean, StudentController.java, as
the backbone of the JSF meritoriousStudents.jsp. The managed bean,
StudentController.java, interacts with a stateless session bean, StudentManager.java which
uses Hibernate framework to implement the functions: addStudent(), deleteStudent() and
getAllStudents(). Their signatures are given below:
public int addStudent(int id, String name, int age, double cpa)
Page 6 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT
package ems;
import java.util.ArrayList;
String id;
int numericId;
String name;
String age;
int numericAge;
String cpa;
double numericCpa;
// implementation missing
}
Page 8 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT
(b) The Manager class, StudentManager.java, implements the addStudent function, the
signature of which has been given above. Assuming that the sessionFactory object
has already been instantiated, implement the addStudent function that uses the
Hibernate framework to persist records in the database table. Assume the entity
class Student with appropriate attributes and accessors already exist.
[7 marks]
(c) The JSF page meritoriousStudents.jsp uses a data table to display all students and also
to delete students as shown in figure 4. At the same time, it provides for
corresponding textboxes in the footer of each column to enable the addition of new
students. Implement the meritoriousStudents.jsp page.
[10 marks]
(Total: 25 marks)
Question 5
(a) One of the most important principles on which REpresentational State Transfer
(REST) is based is “Uniform Interface”. Describe this principle.
[4 marks]
(b) John Smith is the owner of a hardware shop that sells construction items to its
customers. He is currently using a Java application to control the sale and stock of
his materials. To further expand his business, John Smith is considering to open two
more shops around the island. He has hired you as consultant to demonstrate the
suitability of RESTful web services for managing the sales of his items in the three
stores. You decided to create a prototype to show Mr Smith how the system will
work. You create the following Item model with its getters and setters.
public Item() {
}
Your prototype contains an ItemService class that uses a hashmap instead of a database.
The ItemService class implements the CRUD (create, retrieve, update, delete)
functionalities on this hashmap. Part of the ItemService class is shown below:
public ItemService(){
items.put(1, new Item(1,"Bricks", 500));
items.put(2, new Item(2,"Cement", 25));
items.put(3, new Item(3,"Iron", 50));
}
(i) Complete the implementation of the ItemService class by giving the four methods
necessary for the CRUD functionalities.
[8 marks]
The ItemResource class uses HTTP methods to map the CRUD operations to HTTP
requests with the root resource being exposed at “items” path. Part of the ItemResource
class is given below.
@Path("/items")
public class ItemResource {
@GET
@Produces(MediaType.APPLICATION_XML)
public List<Item> getAllItems(){
return is.getAllItems();
}
(iii) Write a function DeleteItem that can be used in Mr Smith’s Java application to
delete an item through the web service.
Page 10 of 10