Preparations for Debugging a Servlet

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.


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



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

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

       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.

       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.)

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



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

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