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:
- Ensure that you are in the Java EE perspective.
- Right-click on JSPBookDemo, and click
Run As > Run on Server.
Eclipse displays a window containing the servlet containers it knows about.
- 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.
- 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.
- While in the JavaEE perspective, set some break points in the source files by double-clicking in the left hand margin of the
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
- To launch the debugger, right-click on the JSPBookDemo project, and click
Debug As > Debug on Server.
- 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.
- If you are asked to switch modes, click
OK to do so.
The web interface appears.
- Type 1111 in the Stock Number field, and click
Read.
- 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.
- Press
F6 to step through line by line.
- 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.
- Press
F6 to step over the open instruction.
- Hover over
ls-file-status to examine its value.
- Click
Run > Terminate to stop the session.
You have now completed the tutorial.