Show TOC Start of Content Area

Procedure documentation Preparations for Debugging a Servlet  Locate the document in its SAP Library structure

 

In the following scenario, you will incorporate a deliberate error in a servlet, rebuild the Web application, and deploy it so you can start debugging.

 

Prerequisites

This graphic is explained in the accompanying textThis graphic is explained in the accompanying text

The Software Deployment Manager (SDM) must be launched before deploying the Web application.

 

Procedure

...

       1.      Open the source code of the servlet QuickReservationServlet.java In the J2EE Explorer, double-click J2EE_QuickCarRentalWeb   source        QuickReservationServlet.java

       2.      Display the source code and navigate to the saveActionmethod.

 

This graphic is explained in the accompanying text

 

       3.      Change the statement:

 

String pickupLocation = request.getParameter("pickupLocation");

 

as follows:

 

String pickupLocation = request.getParameter("pickup");

 

As a result of this simple typing error, no valid value is assigned to the pickupLocation variable and the program terminates with an exception.

 

 

This graphic is explained in the accompanying text

 

       4.      Save the change.

       5.      Choose Project -> Rebuild All from the menu.

       6.      Create an EAR file.

In the J2EE Explorer, right-click the project node J2EE_QuickCarRentalEar and choose Build EAR File from the context menu.

       7.      Deploy the EAR file.

In the J2EE Explorer, right-click the node J2EE_QuickCarRentalEar J2EE_QuickCarRentalEar.ear and choose Deploy to J2EE engine from the context menu. (Note: The SDM must be launched for a successful deployment.)

 

This graphic is explained in the accompanying text

 

       8.      After the successful deployment start the Web application using the following URL:

http://localhost:50000/QuickCarRental

 

Result

An error message occurs during the execution of the application when you try to store a reservation using the button Add Reservation.

 

This graphic is explained in the accompanying text

This means that the error occurs during the call of the saveBooking method, which is called in the servlet method saveAction.

 

Next step:

Debugging a Servlet

 

End of Content Area