Previous Topic Next topic Print topic


Running and debugging

Run the application

Now that you have created and built the COBOL and Java programs in Eclipse projects, you can run the completed application.

To run the application:
  1. Ensure that you are in the Java EE perspective.
  2. Right-click on JSPBookDemo, and click Run As > Run on Server.

    Eclipse displays a window containing the servlet containers it knows about.

  3. Select the one you want to deploy to, which in this case is Apache Tomcat v7.0 Server, and click Finish.

    This action launches the servlet container, builds the Web application, and deploys it to the server. It then opens a Web page displaying the application.

  4. To test it, type 1111 in the Stock Number field, and click Read.

If you have followed the instructions carefully, and built the projects correctly, the system will respond by displaying the book Oliver Twist by Charles Dickens. If so, click End Session and proceed to the debug task.

If, for some reason, the application fails to deploy, you will need to retrace your steps and re-check what you have done. It may be necessary to start from the beginning.

Debug the application

Having successfully run the sample application, you can now use the debugger to control the execution of both the Java and COBOL code by setting breakpoints, step through the code, and examine the contents of variables.

  1. Set some break points in the source files by double-clicking in the left hand margin of the COBOL Editor next to a line you want to stop at. For example:
    • Set a break point in BookServlet.java in the performRead function
    • Set another in BookInterface.java in the readBook method
    • Set a third in book.cbl in the do-read-record section
  2. To launch the debugger, right-click on the JSPBookDemo project, and click Debug As > Debug on Server.
  3. If you are debugging immediately following running the application, the server is already running, and you need take no action. Otherwise, select the one you used for running the application previously. Click Finish.
  4. If you are asked to switch modes, click OK to do so.

    The web interface appears.

  5. Type 1111 in the Stock Number field, and click Read.
  6. Click Yes to confirm perspective switch.

    If you have set the break points as instructed, the debugger will stop in BookInterface.java in the readBook method.

  7. Press F6 to step through line by line.
  8. Press F8 to resume execution. The debugger stops at the break points that you selected, and eventually switches from Java code into the COBOL program.
  9. Press F6 to step over the open instruction.
  10. Hover over ls-file-status to examine its value.
  11. Click Run > Terminate to stop the session.

You have now completed the tutorial.

Previous Topic Next topic Print topic