DA374A Network Applications
Preparation for Lab3
Experiment with Java Application Tier Technologies
Many real applications can be implemented on this architecture. In this lab, you are required to implement a 3-tier travel reservation system (TRS). The application is used to:-
Find and book flights from Stockholm to other parts of the world (1); Reserve hotels in the destination city if traveler wishes so (2);
Process payment for bookings/reservations (3)
Note: The requirements in (2) and (3) are managed by third party applications outside TRS. These applications are called
HOTELAPP for hotel reservation and
BANKAPP for banking operations (transaction processing and currency conversion)
Browser
Servlet JSP
EJB
EJB
Java GUI or command line app.
Client
JSP
Web server
Servlet
EJB
EJB
EJB
Application server
HOTELAPP (JMS)
BANKAPP (WS)
Database Server
(not yet impl.)
The client-tier contains two interfaces:
a web browser for customers (buyers)
a non-browser desktop client (e.g. command line) for administrative purposes (in
house use).
The non-browser client shall directly access the EJB-tier to perform important system administration and maintenance functions such as:
Destination data update: (Cities, airports codes and air fare data). Currency conversion rate updates,
The browser client shall have access to the web tier. It may send the following requests to the web tier:
- Provide information on foreign exchange rates
- Calculate air fare for flights between two cities (airports) in customers currency.
- Make payments if the proposed flight is confirmed.
The web-tier contains Java servlet and JSP components to handle client http requests. You shall build appropriate user interfaces using JSP. The servlets shall be used for routing requests and responses between the client and the application tiers.
The application-tier of TRS is responsible for processing the business logic of flight booking and currency conversion. This includes the following functions:
Calculate air fare in SEK (base currency) based on travelers age
Simulate payment processing for a confirmed flight in customers currency Save flight booking data
Reserve hotel rooms
Send confirmation e-mail to client.Database-tier *
The following tables and columns are needed to persist the data. However, since we have not covered that part yet, you can store the data in the application servers memory for the time being.
Table 1: Destinations: contains at least the following fields:City name
Airport code
Fare (price) in SEKTable 2: Reservation: contains at least the following fields: Passenger Name
Passport number
DestinationDate
Fare (fee)Table 3: Exchange rate: contains at least the following fields: Currency code
Multiplier
Operations
1. From the admin client (desktop application):
The admin client is a java command line client: It is used by the FRS administration staff to update destination and currency exchange information. This client interacts directly with the EJB components from console or a swing GUI.
- 1.1. Perform Add/Update/Delete operations on the destination and currency tables.
- 1.2. Contact a web service in the banking application (BANKAPP) to update currency
conversion rates.
2. From the browser client (on the travelers computer)
FRS performs reservation operations for the traveler data according to the application logic explained below.
Web tier requirements: the browser client has the following features:
- A JSP page opens on the client browser to accept origin and destination inputs,
travelers age and the payment currency.
- The client information is passed to a servlet.
- The servlet forwards the request to the appropriate component in the application tier
- The same servlet collects the response from the application tier processing
- The servlet routes the result back to the client via another JSP page.
- If the client agrees, booking shall be processed (in the same manner as above).
You may modify your JSPs from the previous lab to create the user interface required on this lab. For example, you can create JSP files which display simple forms like the following:
Search Flights
Travel from ____ Travel To Age Currency Calculate Fare
From
To
Exchange Rate Information
Convert
Button Actions: Pressing any of the above buttons (Calculate Fare and Convert) should trigger the invocation of appropriate EJB beans in the application tier.
Convert: Calculates currency exchange rates from currency X currency Y. Calculate Fare: Calculates and returns the travel fare according to the formula:
Fare = Base_Rate * (1 Traveler_Type)* ExRate Base_Rate is a fixed price base set for each destination which can be read from the table directly.
Traveller_Type is used to calculate discount for the traveler based on his/her age group
Type Discount Infant ( < 2 years) 0.9 Child (2-12 years) 0.33 Senior/pensioner (> 67) 0.25 Adult (13-67 years) 0.0
ExRate is the exchange rate calculated for the buyers currency (say CCC) using the following formula
ExRate to EURO = EUR / CCC
ExRate from EURO = CCC / EUR
For example, if the client wants to see the price in Swedish Kronor and enters SEK, the program calculates the exchange rate between Euro and Krona by getting the multipliers of each currency from the exchangerate table and performing the division as above.
Ticket Reservation
- When an appropriate client request is submitted, the calculated fare (price) is returned to the client through another JSP page (e.g. Price.jsp).
On the price.jsp page, a checkbox and two buttons shall be displayed. Chceckbox for travelers who want to reserve hotel rooms
Buttons to choose from Book or Cancel. - If the client wants to Book reservation, he/she shall be redirected to a page where a data entry form for the following information has to be provided:
a. Name
b. Passport Number
c. E-mail address
d. Credit card number
e. Date of departure, etc. - Simulate bank application and payment processing:
If the client fills the form properly, our TRS application invokes a web service to talk with BANKAPP to check if the client has sufficient funds and perform the transaction as follows:
a. If the client does not have funds, the booking shall be cancelled. A message shall be returned to the client why the booking is not performed.
- If the client has funds,
- Another web service call shall be made to the Banking application to
update the balance of the client (debit by the fare amount).
- The Banking application updates the clients account and confirms
back.
- Another web service call shall be made to the Banking application to
- If the bank confirms payment,
i. the reservation table shall be updated with the travelers details ii. A confirmation email is sent to the client
4. Simulate Hotel Reservation
- If the client indicates that he/she wants to reserve a room, our TRS notifies a hotel
application (HOTELAPP) about it. TRS and HOTELAPP communicate via a JMS
queue only.
- When a hotel reservation is to be made, TRS sends relevant information such as
passenger name, passport number, date of arrival, etc., to HOTELAPP.
- Simulate the operation of the HOTELAPP application by creating a message bean that
reads from the JMS queue and parses the message to extract the reservation data.
Sample Destination data
Sample Exchangerate data
No. |
Code |
Airport/City Name |
Base Rate |
1 |
LAX |
Los Angeles |
8500 |
2 |
CPH |
Copenhagen |
2500 |
3 |
CDG |
Paris (Charles De G.) |
4500 |
4 |
LHR |
London (Heathrow) |
6500 |
5 |
FRA |
Frankfurt |
3500 |
Weight is interpreted such that 1SEK = 1/1.30DKK = 1/9.90EUR = 1/9.20USD, etc.
No. |
Currency |
Code |
Weight |
1 |
Danish Kronor |
DKK |
1.30 |
2 |
Swedish Kronor |
SEK |
1 |
3 |
Japanese Yen |
JPY |
0.07 |
4 |
Russian Rubble |
RUB |
0.14 |
5 |
US Dollar |
USD |
9.20 |
6 |
Euro |
EUR |
9.90 |
7 |
British Pound |
GBP |
14.10 |
Sample Flight Reservation data
Name |
Passport No. |
Destination Code |
Payment Currency |
Payment Amount |
Mans |
D12345 |
CPH |
DKK |
1234 |
Maja |
S23456 |
FRA |
SEK |
2345 |
Pelle |
N34567 |
OSL |
NOK |
1058 |
Laban |
R45678 |
DME |
RUB |
9621 |
Frida |
U56789 |
LAX |
USD |
853 |
Bill |
F67890 |
CDG |
EUR |
684 |
Sample Hotel Reservation data
Example:
Required: Air fare calculation for Laban (72 years old)
Name |
Passport No. |
Arrival Date |
Mans |
D12345 |
30/11/2016 |
Maja |
S23456 |
29/11/2016 |
Pelle |
N34567 |
29/11/2016 |
Bill |
F67890 |
27/11/2016 |
Inputs:
Route: Traveller type: Currency:
Stockholm Copenhagen Senior (25% discount) Danish Kronor
Solution
Hence, the fare is
2500 * (1 0.25) = 1875 SEK. = 1875 * 1.30 = 1442.31 DKK
Reviews
There are no reviews yet.