Debug servlets

Debugging servlets is a special case of debugging classes loaded through a custom class loader. Servlets run in the Java™ runtime of the IBM® HTTP Server. You have several options to debug servlets.

The easiest way to debug Java programs and servlets that run on your iSeries™ server is to use the IBM iSeries System Debugger. The IBM iSeries System Debugger provides a graphical user interface that enables you to more easily use the debugging capabilities of your iSeries server.

For more information about using the iSeries System Debugger to debug and test Java programs and servlets that run on your iSeries server, see IBM iSeries System Debugger.

Another way to debug servlets is by following the instructions for classes loaded through a custom class loader.

You can also use the interactive display of your server to debug a servlet by completing the following steps:

  1. Use the javac -gcommand in the Qshell Interpreter to compile your servlet.
  2. Copy the source code (.java file) and compiled code (.class file) to /QIBM/ProdData/Java400.
  3. Run the Create Java Program (CRTJVAPGM) command against the .class file using optimization level 10, OPTIMIZE(10).
  4. Start the server.
  5. Run the Start Service Job (STRSRVJOB) command on the job where the servlet runs.
  6. Enter STRDBG CLASS(myServlet), where myServlet is the name of your servlet. The source should be displayed.
  7. Set a breakpoint in the servlet and press F12.
  8. Run your servlet. When the servlet hits the breakpoint, you can continue debugging.