1. Reservation Project: Steps for creating Reservation JavaDB

  1. On Services panel, select Databases then right click and select Create Database…
  1. Specify database name, username, password, and database location as follows then click OK.

  1. On the newly create database, expand the tree and right click on Tables, then click Create Table…
  1. Type the detail of the table as follows.

  1. To insert initial data, right click on the Tables, select “execute command…” and execute the SQL statements as follows, then click the execute button at the top right corner of the screenshot.

Steps for creating ReservationService

  1. On the project panel, right click and select “New Project…”
  1. Select “Web Application” then click Next.

  1. Type the project name “ReservationService”, then click Next.

  1. Click Next, to accept the default setting.

  1. Click Finish
  1. On the newly create project, right click on the project name then New->Java Class
  1. Type the class name and package as follows, then click Finish.
  1. Copy the Reservation.java code provided into the class.
  1. Right click on the project name in the project panel then click “Run”, the web page should be shown as follows.
  1. Check the web service by browsing to the result should be as follows.

Steps for creating ReservationClient

  1. On the project panel, right click and select “New Project…”
  1. Select “Web Application” then click Next.
  1. Type the project name “ReservationClient”, then click Next.
  1. Click Next, to accept the default setting.
  1. Select “Visual Web JavaServer Faces” framework, then click Finish.
  1. On the newly created project, right click on “ReservationClient” and New->Web Service Client…
  1. Select WSDL URL and copy wsdl URL of the ReservationService into the textbox, then click Finish
  1. Right click on “Web Pages” and then New->Visual Web JSF Page.
  1. Type the file name as follow, then click Finish.
  1. On the newly create page, click “JSP” tab then copy the Reserve.jsp code provided into it.
  1. Then, click “Java” tab and copy Reserve.java code provided into it.
  1. On the project panel, double click on SessionBean1.java.
  1. Then, copy the provided code for SessionBean1.java into it.
  1. Right click on Reserve.jsp and select “Save as main page”
  2. On the project panel, right click on the project name then select Run the result should be as follows.

ReservationClient Demo Screenshots

Airline Reservation Web Service and Web Application

After deploying the web service, deploying the web application, and making a connection to the database server, we can browse to to test the airline reservation system as the following screenshot.

Now, we will try to reserve a aisle seat in an economy class by select the location and the class drop-down list to “Aisle” and “Economy” respectively and then click “Reserve”. The result should be as follows.

Now, switching to the database, we can see that the window economy seat has been updated.

Click “back” on the browser to try to reserve another seat. This time, choose “Middle” and “First” and click “Reserve”. Once again, the reservation should be successful.

And the database should be updated as follows.

Now, click back on the browser and try to reserve aisle economy seat again. This time the reservation should not be success and there should be a message “This type of seat is not available. Please modify your request and try again.”

2. PhoneBook project: Steps for creating PhoneBookDB JavaDB

  1. On Services panel, select Databases then right click and select Create Database…
  1. Specify database name, username, password, and database location as follows then click OK.
  1. On the newly create database, expand the tree and right click on Tables, then click Create Table…
  1. Type the detail of the table as follows, then click OK.

Steps for creating PhoneBookService

  1. On the project panel, right click and select “New Project…”
  1. Select “Web Application” then click Next.
  1. Type the project name “PhoneBookService”, then click Next.
  1. Click Next, to accept the default setting.
  1. Click Finish
  1. On the newly create project, right click on the project name then New->Java Class
  1. Type the class name and package as follows, then click Finish.
  1. On the newly create class, create getEntries() web method
  1. Then create addEntry() web method.
  1. On the PhoneBookService, right click then choose “Run”.
  1. The result should be as follows.
  1. To check the deployment of the web service, browse to

Steps for creating PhoneBookClient

  1. On the project panel, right click and select “New Project…”
  1. Select “Web Application” then click Next.
  1. Type the project name “PhoneBookClient”, then click Next.
  1. Click Next, to accept the default setting.
  1. Click Finish
  1. On the newly created project, right click then New->Web Service Client…
  1. Choose WSDL URL and then copy the wsdl URL of the PhoneBookService into textbox as follows then click Finish.
  1. On the project panel, right click on PhoneBookClient then New->JSP
  1. Type the JSP name “PhoneBook” then click Finish
  1. On the Reserve.jsp, create a html form for add new entry to the phone book and get entry from the phone book.
  1. On the project panel, right click on PhoneBook client then New->Servlet…
  1. Type the Servlet name and package name as follows then click Next.
  1. Click Finish to accept the default setting
  1. In the processRequest() method of the PhoneBookServlet, write code that handles the request from PhoneBook.jsp.

Google Map API

  1. To use Google Map, first we have to convert the address to latitude, longitude coordinates using geocode service and parse the xml result to the xml parser as follows. (For Google API key, go to to sign up for the key.)

//create xml parser

DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

//format the address to send as a parameter for geocoding

String addressParameter=address.replaceAll("\\s", "+");

//request geocoding from Google to translate address to latitude and longtitude

Document doc = builder.parse("

  1. Then extract latitude, longitude coordinates from the resulted xml.

if(doc!=null & doc.getElementsByTagName("code").item(0).getTextContent().equals("200")){

//get the coordinates from the response xml document

NodeList nodeList=doc.getElementsByTagName("coordinates");

String coordinates=nodeList.item(0).getTextContent();

String[]coordinatesArray=coordinates.split(",");

  1. Then we can use the latitude, longitude coordinates to retrieve a map from Google map as follows.

//request map image from Google

out.println("<img src=' GOOGLE_API_KEY +"&sensor=true_or_false'/>");

  1. To run the client, right click on PhoneBookClient, then choose Run.
  1. The result should be as follows.
  1. To go to our jsp page, browse to

PhoneBookClient Demo Screenshots

After deploying the web service, the web application, and connecting to the database server, we can browse to to view the first page of phone book web application as follows.

Currently, the database consists of records as follows.

Now, we will add new entry to the database as the following screenshot.

Then, click “Add”; the result should be like the following screenshot.

Switching to the database, there should be a new entry inserted into the database as follows.

Now, on the web browser, click “Back to Phone Book Homepage” to go back to the homepage. We will try to search for the entry we just added as follows.

After clicking “Search”, the result should be like the following screenshot.

Click “Back to Phone Book Homepage.” Now we will try to search with a last name that would return several entries as follows.

After clicking “Search”, the result should be like the following screenshots.

1