Creating a J2EE-Based Car Rental Application

The Task

Using this tutorial, a Web application for renting cars will be implemented by means of the J2EE standard model.

Users should be able to choose the type of car, pickup and drop off points, and the start and end of the rental period using a Web browser. Finally, they should be able to make a booking. In addition, they should be able to display an overview of all active bookings. They should also be able to cancel existing bookings.

These functions will also be made available to external consumers as a Web service.

About the Implementation Steps

You will begin developing the car rental application by creating the data model on which it is based. To do this, you only need a single table that can record the reservation data. For this purpose you will first create a local table definition using a Dictionary project in the Developer Studio, and then build the associate archive (SDA), before deploying this to the J2EE Engine and creating a corresponding table in the database.

For accesses to table data, you will implement a container-managed persistence entity bean in an EJB module project. The implementation of the application’s business logic (creating a booking, displaying all available bookings, canceling a booking) will be included in a stateless session bean.

Along with the entity and session beans, you will also create and implement the necessary additional auxiliary classes. You will store these auxiliary classes externally in a separate Java project and package them in a JAR file.  

To implement the Web client, you will create a JSP and a servlet in a Web module project. The JSP is responsible for displaying the view in the Web client, while the servlet is needed to pass the data to the JSP in a suitable form and to address the session bean with the requests from the JSP.

You will then generate a Web archive (WAR), which contains the Web resources and the associated deployment descriptors.

The two archives, JAR and WAR, are then combined in an Enterprise Application project, to form a kind of complete application. You must first deploy the resulting archive file (EAR) before you can start and test the car rental application.

In the last step, you will use the complete car rental application as a basis for defining a Web service, and thus make its functions available to other, external applications.

Structure of the Car Rental Application

Objectives

By the end of this tutorial, you will be able to:

!

Comprehend the general process flow when developing J2EE applications using the J2EE toolset in the SAP NetWeaver Developer Studio.

!

Assign components of a J2EE application to the appropriate project types.

!

Create database-independent definitions of tables as part of a project in the Developer Studio, create the associated archive, deploy the archive, and create the table definition in the database.

!

Implement access to table records using entity beans of the type container-managed persistence.

!

Create the business logic components and implement simple business methods.

!

Implement simple user interfaces as J2EE Web clients using JSPs and servlets.

!

Generate the corresponding archives from the available EJB and Web resources.

!

Maintain frequently used entries for different deployment descriptors.

!

Bundle, deploy, and call all resources and archives in one complete J2EE application.

!

Using a session bean implementation as a starting point, define a Web service and make it available for external Web service clients.

Prerequisites

Systems, Installations, and Authorizations

The SAP NetWeaver Developer Studio is installed on your computer.

You can access the SAP J2EE Engine and you are connected to a database instance of the SAP DB.

We also recommend that you install the SQL Studio (although this is optional), so that you can look at the tables you create in the SAP NetWeaver Developer Studio and if necessary edit or delete them.

Knowledge

Java knowledge and basic knowledge of the J2EE programming model would be advantageous.

You have acquired some basic experience with the J2EE toolset in the Developer Studio, for example by working through the Tutorial Writing Your First J2EE Application.

Next step:

Defining a Data Model