Show TOC Start of Content Area

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

 

In the following scenario, you will change the source code of the JSP quickCarRentalView.jsp, 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.

This graphic is explained in the accompanying text

You have the car rental project opened in SAP NetWeaver Developer Studio

 

Procedure

...

       1.      Open the source code of the JSP QuickCarRentalView.jsp: In the J2EE Explorer, double-click J2EE_QuickCarRentalWeb Web content quickCarRentalView.jsp

       2.      Display the source code and navigate to the line at which the reservations are output in tabular form (at the end of the JSP).

 

This graphic is explained in the accompanying text

 

       3.      Change the (HTML) statements (till the end of the file).

 

This graphic is explained in the accompanying text

 

Use the following code:

 


<%  ArrayList reservations = (ArrayList) session.getAttribute(Constants.RESERVATIONS);
  
if  (reservations !=  null  && reservations.size() > 0) { 
    out.print(
"</br>" );
    out.print(
"<table border=\"1\">" );
    out.print(
"<form name=\"reservations\" method=\"POST\" action=\"/QuickCarRental\">" );
    out.print(
"<input type=\"hidden\" name=\"appAction\" value=\""  + Constants.ACTION_CANCEL +  "\"/>" );
    out.print(
"<tr>" );
    out.print(
"  <th>&nbsp</th>" );
    out.print(
"  <th>ID</th>" );
    out.print(
"  <th>Vehicle Type</th>" );
    out.print(
"  <th>Pick-up Location</th>" );
    out.print(
"  <th>Drop-off Location</th>" );
    out.print(
"  <th>Begin Date</th>" );
    out.print(
"  <th>End Date</th>" );
    out.print(
"  <th>Price</th>" );
    out.print(
"</tr>" );
    
for  ( int  i = 0; i < reservations.size(); i++) {
    String[] reservation = (String[]) reservations.get(i);
    out.print(
"<tr>" );
    out.print(
" <td>" );
    out.print(
" <input type=\"checkbox\" name=\"check\"  value=\""  + reservation[0] +  "\"/>" );
    out.print(
"  </td>" );
    
for  ( int  j = 0; j < reservation.length; j++) {
    String value = reservation[j];
    out.print(
"<td>"  + value +  "</td>" );
    }
    out.print(
"</tr>" );
    }
    out.print(
"<tr>" );
    out.print(
"<td align=\"center\" colspan=\"8\">" );
    out.print(
"<table>" );
    out.print(
"<tr>" );
    out.print(
"  <td align=\"left\">" );
    out.print(
"    <input type=\"submit\" name=\"reservationCancel\" value=\"Cancel Reservation\">" );
    out.print(
"  </td>" );
    out.print(
"  <td/>" );
    out.print(
"</tr>" );
    out.print(
"</form>" );
    out.print(
"</table>" );
    } 
else  {
    out.print(
"No Reservations" );
    }
%>

</body>
</html>


 

       4.      Save the change by choosing the appropriate icon in the toolbar.

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

       6.      Create an EAR file.

In the J2EE Explorer, right-click the 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.

 

This graphic is explained in the accompanying text

 

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

http://localhost:50000/QuickCarRental

Result

The change has no effect on the application itself. However, the replacement of the HTML statements with the Java codes enables you to improve the debugging of the JSP page in the next step.

 

Next step:

Debugging a JSP

 

 

 

 

End of Content Area