WebSphere Advanced Single Server Edition: tracing and debugging a servlet

Page Hit Counter is one of the samples that is shipped with the IBM WebSphere Advanced Single Server Edition product. The sample is installed if you selected to install the default resources during the WebSphere Application Server installation. Installing the default resources will also provide an application server called the Default Server.

To use the IBM Distributed Debugger and Object Level Trace (OLT) on the Page Hit Counter servlet, do the following:

  1. Enter the following command to start the WebSphere Advanced Single Server Edition with OLT and the Distributed Debugger enabled:
    startServer -oltenabled -debug
  2. Start the OLT by typing the following in a system command window:
    olt

    The following screen will be displayed:

    npws1.gif (11901 bytes)

    Make sure the Execution mode is Trace and debug. If it is not, select it from the drop down list.

    The Debugger hostname is the name of the machine where the Debugger user interface will be displayed. Assuming that the Debugger is installed locally, enter the host name of the machine on which you are working.

    Keep 8001 for the Debugger TCP/IP port. Only use another port number if port 8001 is already in use on your machine.

    Click Apply.

  3. Invoke the Page Hit Counter servlet by typing its URL in a Web browser:
    http://localhost/WSsamples/DB/index.html

    npws0.gif (14938 bytes)

  4. OLT will trace the initial calls to the Page Hit Counter servlet and JSP file. At this point you should select Options->Step-by-step Debugging Mode.

    Your browser should display this message:

    This page has been requested 2 times
  5. There is also a Reload this page and increment the counter button. To rerun the sample, click this button.

    OLT will start tracing the events as they take place. Because you have selected Step-by-Step debugging mode, you will be asked if you want to step into every debuggable method.

    The first method is the service method of Page Hit Counter servlet and the following dialog box is displayed:

    npws2.gif (4945 bytes)

  6. Highlight the service method and Click OK. This will cause the debugger to come up, and it will put you in the first line of the Page Hit Counter's service method:

    npws8.gif (20616 bytes)

  7. You can now choose to step over methods, step into other methods, or run the program. Click Run in the tool bar pane at the top of the Debugger tool.

    Because OLT is in Step-by-Step debugging mode when it encounters the next debuggable method, it will, again, ask you (using a Method Breakpoints dialog box) if you would like to step into the method.

    Because the Page Hit Counter JSP file includes a Page Hit Counter servlet, OLT will ask you to step into the servlet's service method. Highlight the method and click OK as you did for the last method, and the debugger should come up in CounterServlet.java, as follows:

    npws5.gif (19341 bytes)

  8. You can now choose to step over, step debug, run, and so on. If you click Run, then the Page Hit Counter servlet should run to completion.

    Note: If your browser timed out, see Troubleshooting for instructions on how to increase the browser timeout.

ngrelr.gif (548 bytes)
WebSphere Advanced and Advanced Single Server Edition examples